WordPress is reliable, but that doesn’t mean it is entirely error-free. Every now and then you will encounter errors that seem to put you in a tough spot. One notorious example is the error: “the uploaded file exceeds the upload_max_filesize directive in php.ini”.
This error shows up whenever a user uploads a very large file or theme to the platform. Most long-time WordPress users have encountered this error at least once, so thankfully the fixes are well known.
You just need to get informed about the possible solutions and how to apply them. In some situations, the error shows up without having anything to do with the size of the file you’ve uploaded. In most cases, however, it shows up because of your server settings.
Either way, you will find more about the “the uploaded file exceeds the upload_max_filesize directive in php.ini” error in this article and you will also find out how to fix it. Continue reading to dive into the topic and find a solution.
Let’s explain a bit further what the “the uploaded file exceeds the upload_max_filesize directive in php.ini” error is and why it shows up .
First of all, rest assured that this error is very easy to fix. Secondly, this error is a simple notification that a file you are trying to upload on the site exceeds the upper limit set by WordPress, which is equal to 2 MB by default.
Another cause behind the error is related to the platform where you host your website. Different web hosts have different file size limits. If your host set a lower file size limit like 1 MB, it’s likely you will see this WordPress error quite often.
To understand the process better, here’s how it works: once you try to upload a file and it is too large for the limits set by either WordPress or your web host, the upload_max_filesize directive is exceeded and WordPress sends the error notification. Thisdirective is located in the php.ini file on your web server.
The php.ini file is a default file used for configuration in most apps and platforms that require the use of PHP for functioning properly. Both the relevant directive (i.e. upload_max_filesize) and the file (i.e. php.ini) are mentioned in the message displayed by the error notification.
Since WordPress runs on PHP, it will look at the php.ini file to determine whether the file you are uploading is within the limits set. And, simply put, if it’s too large, PHP will refuse to allow the upload.
Keep in mind that the upload limit is not something you can just change in your WordPress Dashboard. However, you can find out what the limit is if you go to your Dashboard>Media >Add New. The limit will popup under the upload screen, in the message “Maximum upload file size”.
As you can see from the picture, this is an ideal situation as the file size limit is 128 MB, which is more than enough for any file that you may want to upload to your site. However, there are some hosts that set the limit to as low as 1MB.
This means that whenever you will try to upload a larger file, you will get the “uploaded file exceeds the upload_max_filesize directive in php.ini” error or a message that notifies you that you are not allowed to upload the file because of its size.
Now that you know what causes the issue, what can you do to solve it? Well, you have four different options: update the php.ini file, edit the .htaccess file, edit the wp-config.php file, or contact your web hosting support team.
At least one of these solutions should work, regardless of what caused the error to pop up on your site. See each solution described below.
This is probably the most obvious step to take when this error shows up.
As mentioned before, the php.ini file is the default PHP configuration file. Since WordPress uses PHP, this file controls many aspects of the platform, and – implicitly – of your website. You will need to update this file to make sure that everything works as intended.
On most shared web hosts, you can find the file in the wp-admin folder of your WordPress document root directory, and you can just open the file and overwrite the memory limit. To do that, you need to:
1. Log in to your web hosting account and then log in to cPanel
2. Navigate to Files and then File Manager
3. Go to “Document Root for:” and click Go.
4. Navigate to the wp-admin folder
5. Look for php.ini or php5.ini. If there is no php.ini present, create a new file and name it php.ini
6. Open the file and search for “upload_max_filesize”.
7. Change the value of this directive to something higher like 128 MB.
8. Save the changes, and then refresh your website.
Compared to php.ini which controls the PHP settings, .htaccess is a file that controls the Apache Web Server settings. It is responsible for configuring settings for each folder and user, and it lets you customize the web server software the way you want. Fortunately, the maximum file upload size can also be set in this file.
The quickest way to solve “the uploaded file exceeds the upload_max_filesize directive in php.ini” error through the .htaccess file is to edit this file in your file manager. You will need to go to the root directory of your WordPress, locate the .htaccess file and hit edit. If you cannot see the file, make sure that you have set hidden files to be viewable.
To increase the upload_max_filesize directive, add this line at the bottom of the file:
php_valueupload_max_filesize128MContinue to increase the limits until the problem is gone. You can also try setting these other relevant limits higher if you still experience issues with large uploads:
php_valuepost_max_size256M php_valuememory_limit512M php_valuemax_input_time 180 php_valuemax_execution_time 180
Save your changes now and refresh the website to see whether the WordPress error is gone.
If your website refuses to load with a “500 Internal Server Error” after making these changes to your .htaccess file, this could be due to restrictions placed on your server by your web host. In that case, try another method listed here.
If the aforementioned options did not work for you, it’s time to solve the “uploaded file exceeds the upload_max_filesize directive in php.ini” error by editing the wp-config.php file. Even though many people avoid doing this because it can be trickier, it’s not as difficult as you may believe.
Keep in mind that this file contains the most important parameters that make your website work as it should. It is located in the root folder of your WordPress installation and you will need to use your web host file manager or an FTP program to access and edit it.
Here are the steps using a file manager:
1. Navigate to the wp-config.php file and select Edit
2. Scroll down and look for this line:
/* That’s all, stop editing! Happy blogging. */
3. Before the line, paste this code:
@ini_set('upload_max_size' , '256M' )
4. Save the file and try upload your file again
If everything else fails, it is time to contact your web host. Your hosting service provider can modify the limit for you when the “uploaded file exceeds the upload_max_filesize directive in php.ini” error appears.
Your host’s support team should handle this issue quite rapidly, as this is a common request and doesn’t involve a lot of coding. A phone call or email will solve the problem for good.
Immediately after trying one of the solutions mentioned above, you should navigate to Media and Add New to see whether the maximum upload limit changed. You need to do the same after contacting your web hosting support team and see if they’ve changed it correctly. Once set, you will not have to change anything further to upload files within the new file size limit.
Free cheat sheets available
Subscribe to download a set of cheat sheets for CSS, JS, and HTML
You'll receive an email with the cheat sheets in an instant.