Did you just try to upload a file to your WordPress site only to be met by an error message saying “the uploaded file exceeds the upload_max_filesize directive in PHP.ini”?
The error occurs when you are trying to upload a large file which can be an image, plugin, theme, or video. If the file size of the upload exceeds the maximum upload size configuration on your hosting server, you’ll see this error message.
The fix? Edit your server’s configuration settings to increase the maximum upload filesize.
In this article, we are going to help you resolve this issue by extending the server’s default file upload limit.
Don’t worry, it’s not as difficult as it sounds. We will share four different methods and you can choose whichever method you find comfortable and easy to execute.
📚 Table of contents:
- Modify PHP configurations on cPanel
- Edit the .htaccess file
- Edit the wp-config.php file
- Update php.ini via FTP
What causes the “the uploaded file exceeds the upload_max_filesize directive in PHP.Ini” error?
In the introduction, we talked about how your hosting prevents large files like images, videos, plugins, or themes from being uploaded to the server. They want to ensure that the server resources are being fairly shared among its users. By putting a cap on the file size, they make sure that no single website is using a disproportionate amount of server space or memory.
In WordPress, you can check your upload limit by opening the Media Library upload area – Media > Add New.
![maximum upload size on media wordpress](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1024/h:777/q:90/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/01/maximum-upload-size-on-media-wordpress.png)
The good news is you can overcome this hurdle by changing the default limit. However, there are risks involved. One of the most common risks that you run into is by making the slightest of error in the .htaccess or wp-config file and your entire website would come down crashing.
To safeguard your site from such a nightmare, we recommend taking a backup of your website before trying any of the tips in this article.
How to fix the “upload_max_filesize” error in WordPress
To upload a large file into your website, all you need to do is increase the upload limit on your server. We’ll share four different methods to achieve this – at least one of them should work for your site.
Note: You can adjust the upload limit to the desired value as long as your hosting provider supports it. If your file size is 10MB and your hosting supports up to 8MB, then you’d have to move to a better hosting provider.
To discover your PHP memory limit, go to Tools > Site Health > Info.
![site health in wordpress](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1024/h:777/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/01/site-health-in-wordpress.png)
1. Modify PHP configurations on cPanel
Let’s start with the easiest method, which should work fine as long as your host uses cPanel for the hosting dashboard.
If your hosting provider doesn’t offer cPanel, you can try one of the other options on this list.
Here’s how to increase the max upload size in cPanel:
- Log into your hosting account.
- Open cPanel.
- Go to Select PHP Version > PHP Options/Options. Or, in some situations, you might need to look for a tool called MultiPHP INI Editor.
- Change the value for
upload_max_filesize
according to your needs.
![php option in file manager](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1024/h:777/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/01/php-option-in-file-manager.png)
2. Edit the .htaccess file
The .htaccess file lets you control key configuration details for your web server. On many hosts, you can edit this file to increase the max upload filesize limit
Needless to say, it’s an extremely crucial file and should be handled with caution.
To start, connect to your server using an FTP client. If you’re not sure how to do that, follow our detailed FTP guide.
Before making any changes, download a copy of the .htaccess file onto your computer as a backup option. That way, if you encounter a problem, you can just delete the edited file from your website and upload the old file to make things go back to how they were.
![download htacess from htaccess](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1024/h:897/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/01/download-htacess-from-htaccess.png)
Once you have your backup copy, right-click to edit the file on your server. Then, add the following code snippet and adjust the values based on your need:
php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value memory_limit 128M
![editing htacess file - upload_max_filesize directive in PHP.ini](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:858/h:733/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/01/editing-htacess-file.png)
Close the file, go to your website, and check whether you can upload large files.
Some of you may encounter the following error after inserting the code – Warning: PHP runs in CGI-mode.
If you see this message, it means you can’t use this command in the .htacess file because of how your hosting environment is configured. Remove the code snippet and try some of the next methods.
3. Edit the wp-config.php file
The wp-config.php
file contains important configuration details for your WordPress site. Without the config file, you will lose access to your site’s content. Handle the file carefully.
As part of those configuration details, you can make changes to the maximum upload limit on your site.
To begin, connect to your website using an FTP client and download a copy of the wp-config.php
file as a safety net. If anything goes wrong, you can reupload this copy to your site to make things go back to how they were.
Next, edit the file and insert the following code snippet above the /* That's all, stop editing!
line as shown in the image below. Make sure to change the value based on how large files are to be allowed on your website.
@ini_set('upload_max_size' , '128M' );
![editing wp-config file - upload_max_filesize directive in PHP.ini](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:831/h:734/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/01/editing-wp-config-file.png)
Save the file, exit, and check if you can upload large files to your website. If you can’t upload the file, then try the next method.
4. Update php.ini via FTP (didn’t work for us)
The php.ini is a configuration file and modifying it will override your server settings. Updating the file didn’t work for us but it is a popular method recommended by hosting providers so we suggest you give it a try.
Whether or not it works really depends on how your hosting server is configured, so it might work for you even though it didn’t work for us.
Make sure you have backed up your website before proceeding with the steps.
Like all other configuration files (i.e. wp-config and .htaccess), the php.ini should be located in your root folder.
Connect to your website using an FTP client.
If you see an existing file called php.ini, save it on your local computer as a backup. Open the file and you should find an option that says upload_max_filesize = 128M
. Change the value to whatever suits you best.
If you don’t see an existing file called php.ini, you can just create a new one in the root folder. Then, edit it and add the following line:
upload_max_filesize = 128M
Make sure to save your changes when you’re done.
![create new file in file manager - upload_max_filesize directive in PHP.ini](https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:1024/h:777/q:eco/f:avif/https://themeisle.com/blog/wp-content/uploads/2022/01/create-new-file-in-file-manager.png)
Fix the “upload_max_filesize directive in PHP.ini” error for good
In this tutorial, we covered four different ways of fixing the “The uploaded file exceeds the upload_max_filesize directive in php.ini.” error in WordPress.
If none of the methods worked for you, we recommend uploading the file via FTP and then importing it to your Media Library using a plugin like Add From Server. But if that fails too, you will need to talk to your hosting provider about having them increase the upload limit for you.
For more help with WordPress, we have a complete guide to fixing common WordPress errors. We also have a guide that details the basic practice of WordPress troubleshooting.
Do you still have any questions about how to fix the “upload_max_filesize” error? Let us know in the comments below.
Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!