How to Overcome Error The Uploaded File Exceeds the upload_max_filesize Directive in php.ini in WordPress

Posted on

The error “The uploaded file exceeds the upload_max_filesize directive in php.ini” is an error message that appears when users try to upload files, images or themes that exceed the specified capacity.

WordPress has a maximum size limit. This limit varies depending on the settings of the hosting service provider. These settings are usually found in the control panel on the PHP menu. When you violate this limit a pop up error will appear ‘The uploaded file exceeds the upload_max_filesize directive in php.ini’.

How to Overcome Error The Uploaded File Exceeds the upload_max_filesize Directive in php.ini in WordPress

Often this problem appears on websites that have a lot of content. You might think that solving the error ‘The uploaded file exceeds the upload_max_filesize directive in php.ini’ is quite difficult, but it’s not. You just need to change the value of each of the command variables below. Make sure the maximum upload limit is greater than the file size to be uploaded. Here are some ways to fix this WordPress error:

1. Editing the .htaccess File

The fastest way to fix the error ‘the uploaded file exceeds the upload_max_filesize directive in php.ini’ is to increase the maximum PHP resource limit in .htaccess.

The method is very easy. All you have to do is access the root directory of your WordPress repository using a file manager or FTP client. Then, locate the .htaccess file which is usually located in the public_html folder or the root folder of your WordPress installation. Access the file and change some of the values in it.

Increasing the maximum upload can be done by changing the value of the upload_max_filesize command. You do this by adding the line below into .htaccess. You can adjust the value according to your needs. In the example below I use the value 256M which means the maximum upload is 256 Megabytes.

php_value upload_max_filesize 256M

When finished, try to upload the failed file again. If this method works, no errors should appear.

2. Editing the wp-config.php File

Another way to deal with the error ‘the uploaded file exceeds the upload_max_filesize directive in php.ini’ is to change the configuration in the wp-config.php file. This file is also located in the WordPress directory in the same folder as the .htaccess file.

Once you open it, add below line of code,

@ini_set(‘upload_max_size’ , ‘256M’ );

Don’t forget to save it.

Once done, please refresh your browser then try uploading the same file. If successful there should be no error that appears again.

3. Changing Configurations in cPanel

If you have access to cPanel, you can use this method by accessing the Select PHP Version feature. This feature is in cPanel hosting. You can access this feature via “cPanel » Select PHP Version » Switch to PHP Options”.

Not only changing the maximum file upload size limit, in this menu you can also set the memory limit, maximum post size, and so on. By default, the maximum limit setting has been set by the hosting service provider, but you can change it again according to your needs.

When finished, don’t forget to click “Save” to save it.

4. Updating the php.ini File

The fourth way that you can try is to change the configuration in the php.ini file. This method can only be used by those of you who have access to the server or for Virtual Private Server (VPS) users with root access.

You may have been wondering, the error ‘the uploaded file exceeds the upload_max_filesize directive in php.ini’ mentions php.ini but the previous methods haven’t covered this file.

If you take a closer look at the error it does mention something wrong with the php.ini file. The php.ini file is a file that holds all PHP constraint configuration variables.

The php.ini file sometimes requires higher (root) access to the server which is not allowed for normal users or shared hosting users. For example on Niagahoster. You cannot access PHP files on Niagahoster, but all restrictions on using PHP have been set as closely as possible.

Meanwhile, for those of you who use a Virtual Private Server (VPS) service, it is very possible to change the configuration in the php.ini file. So this solution is perfect for you to apply if you encounter the error ‘the uploaded file exceeds the upload_max_filesize directive in php.ini’ on the VPS.

To change it, access the file in the /etc/php/7.0/cli/php.ini folder. That is an example of the directory used by PHP version 7. Other PHP versions are sometimes located differently. The location of this file also depends on the hosting service provider you are using. You can also check using the command $ rpm -qc php-common.

Once you have accessed the file, look for the line upload_max_filesize and increase its value. You may raise some limits as below.

upload_max_filesize = 256MB
post_max_size = 256M
memory_limit = 512M
max_execution_time = 180

Do not forget to save the configuration that has been done.

When finished, please access WordPress again and try uploading the file that failed to upload earlier. If it works, no problems or errors should appear.

5. Contact Customer Support

If all the methods discussed above have not been able to fix the error ‘the uploaded file exceeds the upload_max_filesize directive in php.ini’, you can contact customer service.

Provide information that is roughly needed by your hosting service provider’s customer support such as screenshots and steps when encountering the error. As little information as you provide will be able to help customer service to find out the cause and provide a solution.

Before that, you may be able to see the maximum upload limit and inform customer service about it. You can access this information through the “WordPress Dashboard » Media » Add New menu.

Closing

Up to this point you have learned several ways How to Overcome Error The Uploaded File Exceeds the upload_max_filesize Directive in php.ini in WordPress.

In the implementation process, you may encounter other problems or difficulties.

If you have some other questions to resolve the error ‘the uploaded file exceeds the upload_max_filesize directive in php.ini’ in WordPress, don’t hesitate to let us know by leaving a comment in the column below.

[hurrytimer id=”247″]