» » » How to increase the maximum upload filesize in WordPress

How to increase the maximum upload filesize in WordPress

posted in: WordPress
3 min read

Last year, I wrote, “How to increase the maximum file upload size in Multisite WordPress Network with WHM“. Today I gonna share how to increase the maximum file upload size in WordPress(Not Network site).

 

Screenshot below shows where we will set today.

 

What we are looking for three settings below

  • memory_limit
  • post_max_size
  • upload_max_filesize

From the frontend, you can add this PHP code into your PHP file. This file will print out all PHP setting for your site. Beware this information can go publish if you forget to delete this code.

phpinfo();

 

PHP setting for WordPress

The PHP setting for increasing the maximum upload file size must be done on the server. It can not be set in the WordPress single site. There are some options you can try. Let’s do it.

 

Option 1: Change the PHP setting in cPanel

If you use the host that provides cPanel, you can change the PHP setting by navigating to Software then click on “Select PHP Version”. On the “PHP Selector | extensions” page, click on “Switch To PHP Options”. At the “PHP Selector | options” page, you can change the three value as you like.

  • memory_limit
  • post_max_size
  • upload_max_filesize

 

Option 2: Create or Modify the php.ini file

  • If your host allows you to create or modify the PHP setting for your site then you can navigate to the webroot of your WordPress site. You should check with your host provider for the ability to set the PHP setting at the server. To make sure what method they allow you to set.
  • Then create or modify the three PHP setting below in the php.ini file
upload_max_filesize = 10M
post_max_size = 12M
memory_limit = 32M

Option 3: Create or Modify the user.ini file

  • If the php.ini doesn’t work, it could be that your host has the global settings locked down. Your host may allow changing the PHP setting via the user.ini file. You should check with your host provider for the ability to set the PHP setting at the server. To make sure what method they allow you to set.
  • If your host allows changing the PHP setting via the user.ini file then you can navigate to the webroot of your WordPress site.
  • Then create or modify the three PHP setting below in the user.ini file
upload_max_filesize = 10M
post_max_size = 12M
memory_limit = 32M

 

Options 4: Modify .htaccess file

  • If your host doesn’t allow changing the PHP setting in the php.ini or user.ini file then you can set the PHP settings into the .htaccess file. Note that the .htaccess file is a hidden file and it is a very important file for WordPress single site that you NEVER want to delete it or modify it without any knowledge what you are doing.
  • Backup your .htaccess file before continue
  • Navigate to the webroot and find .htaccess file. Then add three PHP settings below into the file and save.
upload_max_filesize = 10M
post_max_size = 12M
memory_limit = 32M
  • After saving the file and refresh your WordPress site, you see “internal server error” on the screen. Most likely your server is running PHP in “CGI mode” which means you can not use the .htaccess method.

 

Option 5: Use the ini_set() which is a PHP function

    • Open the functions.php in your active theme folder. Example, wp-content/themes/YourActiveTheme folder. If your theme doesn’t have one, create a new file. You should set the child theme when you choose this option. Otherwise, when your active theme is updated, the functions.php will be overridden.
    • add the code below in this file
@ini_set( 'upload_max_filesize' , '10M' );
@ini_set( 'post_max_size', '12M');
@ini_set( 'memory_limit', '32M' );

 

Now you can check and test it by using the Media upload. Simply, login to WordPress single site and go to Media menu. Then click on Add New. You will the text that tells you the maximum upload file size there.