Increase WordPress File Upload Size Limit on Shared Hosts

Print View Mobile View

Most hosting services have an upload size limit in place which prevents users from uploading large files. Just now I faced such an issue while uploading an image on another website. I never had such a problem on SumTips as all images are way below the set limit. So I tried uploading a MP3 file and voilà:

WordPress file size upload error
WordPress file size upload error

Some of you maybe already knowing the solution to this issue, but I didn’t. And since I will have to make this change again sometime, I’m posting the fix here.

Htaccess method

The quickest way is by using .htaccess file, which is available and work for majority of web hosts. You should find this file in the root directory of your server. If it doesn’t exist, create a new plain text file and name it .htaccess while saving. Also makes sure that your FTP client display hidden files.

Alter the .htaccess file by adding the following to it:

php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200

Replace the highlighted value with your desired file size. For instance, lets say you would like to increase the maximum supported size to “50MB”, simply replace “20M” with “50M”. max_execution_time value is in seconds.

For this method to work, your server should have Apache’s AllowOverride option set. This is necessary for a user to be able to override server’s configuration.

PHP.ini method

In the root WordPress folder, you should find a file called php.ini. This file handles standard PHP functions for WordPress. If you are on a shared host, you may not see this file.

Open the file and change the following variables to your desired file size.

upload_max_filesize = 20M
post_max_size = 20M
max_execution_time = 200

Save php.ini file and restart the server.

Function method

Another way to increase upload size is by editing your theme’s functions.php file. This didn’t work for me, but you can try to see if it does for you. Add the following anywhere between <?php and ?>:

ini_set('upload_max_size','20M');
ini_set('post_max_size','20M');
ini_set('max_execution_time,'200');

That should do it.  See if it worked by visiting the upload page.

2 thoughts on “Increase WordPress File Upload Size Limit on Shared Hosts”

Comments are closed.