How to Increase Maximum Upload File Size in WordPress

At some times we are facing issue while uploading a high file size in WordPress and WordPress shows this error “exceeds the maximum upload size for this site”. So then instead of finding any ready WordPress plugin to fix this issue we can do it manually without plugin.

As per the PHP Documentation, there are so many server settings available to handle upload files but for our need we required 6 main settings for larger file uploading.

Many hosting servers keeping this limit low by default, this is not exactly issue in WordPress. This low limit is set because of security and efficiency of your site so user can not upload larger videos or files to our site to grinding servers to a halt. Let’s see how can we fix this.

1. Use PHP Function : ini_set()

You have to login your site by FTP or SSH and then look for config.php file. You can see this file present in your WordPress site root directory.

Just edit this file and place below code in this file at the beginning of the file or end of the file and save it.

@ini_set('max_execution_time','300000');
@ini_set('max_input_time','300000');
@ini_set('max_input_vars','300000');
@ini_set('memory_limit','800M');
@ini_set('post_max_size','800M');
@ini_set('upload_max_size','800M');

Just edit this file and place below code in this file at the beginning of the file or end of the file and save it. You can add this code in your functions.php file of activated theme or it can be add in plugins file as well. But I suggest add this code in config.php file only because this files running to first initialization of WordPress.

2. Add code to “.htaccess” file

The .htaccess file is a hidden file present in root directory of WordPress site. This file contains a code to set server behavior as required for our site. You have to login with FTP or SSH and look for this .htaccess file and edit it. Once you open file in edit mode just add below code in end of the file.

php_value max_execution_time 300000
php_value max_input_time 300000
php_value max_input_vars 300000
php_value memory_limit 800M
php_value post_max_size 800M
php_value upload_max_filesize 800M

Once you add code and save it just run website in browser and if you see any message like “Internal Server Error” that means server php is running on CGI Mode. And you have to rollback .htaccess changes because it doesn’t allowed this command by .htaccess file.

3. Create .user.ini file in root directory

This file also handles server configuration for specific site. You have to do same login by FTP or SSH and look for .user.ini file. If you dont see this file then create it or modify existing. Below code you have to add in this file.

max_execution_time = 300000
max_input_time = 300000
max_input_vars = 300000
memory_limit = 800M
post_max_size = 800M
upload_max_filesize = 800M

4. Change .ini file settings in cpanel

If you having cpanel, then you can see one option called “MultiPHP INI Editor”. Just click on this option and select your domain that you want to increase limits.

This confirmations works as per the selected domain so you can see one option there “upload_max_filesize” just increase it as per you required and click on Apply button.

Using this method also can be increased file size limits.

5. Create php.ini file manually

If you login with FTP or SSH, then in your project root directory, you can create php.ini file if its not exist or else you can modify it. In that file you have to find those 3-4 settings and modify those values. Or else just copy and paste below code in your php.ini file and save it.

max_execution_time = 300000
max_input_time = 300000
max_input_vars = 300000
memory_limit = 800M
post_max_size = 800M
upload_max_filesize = 800M

6. Switch to PHP options in cPanel

If you have  for you website then you can do this easily with php option. Just search for the “Select PHP Version” and open it by clicking on it. You can see one option “Switch to PHP options”.

Now you can see all options and its default values. Just modify those as per your need and save it.

Final Output

From above 6 options you can use any one which works for you, and then if you can go back to you WordPress media library to upload files. You can see file upload size will be increase from 2MB to 800MB as per our modifications.

Conclusion

As you can see its not a complex part to change maximum upload file size and some other settings. Using these above methods we can change our server PHP configuration to run site properly as per our requirement. There is one more method available to increase file upload size with the help of upload_size_limit filter provided by WordPress which we have covered as well in a separate post.

If this article helpful to you, then please share this article with other so they will not stuck to upload maximum files in WordPress media uploader.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.