Trying to add something to the WordPress site only to get a message stating that: "The uploaded file exceeds the upload_max_filesize directive in php.ini".
This error message can appear when you upload large files, videos, plugins, themes, any other kind of file that you upload to your WordPress account.
In this post, we're going to help you solve the issue and make it so that you can upload your larger files. In fact, we're going to cover:
- What triggers "the uploaded file exceeds the upload_max_filesize directive in php.ini".
- How to resolve "the uploaded file exceeds the upload_max_filesize directive in php.ini"
What are the causes of "the uploaded file exceeds the upload_max_filesize directive in php.ini"
So why does this happen? In order to protect the capacity of your server, web hosting services set a limit to the overall size of a file that can be uploaded.
This limit is specified in megabytes in the upload_max_filesize directive in php.ini.
The upload_max_filesize directive itself is configured in the php.ini file, which is the default server configuration file for programs running PHP.
The combination of these two – upload_max_filesize and php.ini – are what the error message you see is referring to.
It is important to note that this upload restriction is not a WordPress configuration. However, you can see this limitation on your WordPress site if you go to the Media tab to add new files or perfrom any other types of uploads (such as a backup) that is larger than this maximum upload limit
How to verify the current upload limit in WordPress
As you can see in the screenshot above, the default limit is 128 MB, which is quite good and is unlikely to pose any problems, under most conditions. However, a number of other hosts set the default to as as small as 2 MB or 4 MB.
This means that whenever you attempt to upload a file greater than that amount, you will see "the uploaded file exceeds the upload max filesize directive in php.ini" or a related message like "file name exceeds the maximum upload size for this site."
How to Fix the uploaded file exceeds the upload max filesize directive in php.ini
You need to increase the file size upload limit to correct this problem. This means that you need to change the value of the upload_max_filesize directive in your php.ini configuration.
There are many different ways you can do this – the method you select will depend mostly on the setup of your host.
1. Speak to your web hosting support
Although we're going to cover some approaches that you can implement on your own, the easiest approach is typically to reach out to your host's support and ask them to raise the maximum upload size for you.
This is a simple request, your host's help should know exactly what you want, and it should only take a few minutes of your time.
2. Edit the php.ini file from cPanel
If your host uses cPanel, you should be able to update your php.ini and upload_max_filesize directives from the cPanel dashboard.
Then pick your WordPress site from the drop-down menu. After that, you will be able to modify the upload_max_filesize directive for that site:
screenshot of Changing the upload max filesize directive for cPanel
Increase the value depending on your requirements.
3. Edit your php.ini via FTP
The php.ini file manages how the server operates on PHP programs.
Unfortunately, depending on the limits of your host, you might not be allowed to use or modify php.ini settings. For this reason, the use of .htaccess (which we'll discuss in the next section) may also be a potential solution.
However, you can first try to see if you are allowed to use php.ini on your host.
To get started, connect to your server via FTP and go to the root folder of your domain.
If you already see a php.ini file in the root folder, you can update the file. If not, make a new file and call it php.ini:
Screenshot of - How to create a new file for php.ini
Then add or change the following code snippet:
Screenshot of upload_max_filesize directive
Paste the code snippet and change the value to fit your requirements.
When you are modifying an existing php.ini file, find the same directives in the existing file and change the numbers to solve your problem.
upload_max_filesize = 128M
post_max_size = 128M
memory_limit = 128M
Certain hosts will require you to apply the suPHP directive to the.htaccess file of your site such that the above modifications will work properly.
To do this, you can also update your .htaccess file using PHP and apply the following code to the top of the file:
<IfModule for mod suphp.c>
SuPHP ConfigPath/home/yourname/public html
Please ensure that the path is updated with the real file path of your site.
4. Increase the value of upload max filesize by editing .htaccess file
If the aforementioned techniques don't work, you may still try modifying the upload max filesize directive by updating the.htaccess file on your site.
To get started, access your site via FTP and modify the .htaccess file in the root folder of your site.
Then apply the following code snippet, make sure you change the values based on your needs:
php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value memory_limit 128M
If you get an internal server error message after inserting this code fragment above, your server is likely running PHP in CGI mode, which means that you cannot use these commands in your .htaccess file. Remove the snippets you just inserted, and your site should start running correctly again.
Do you want a fast website?
Who am I kidding? Don't we all?
So why do so many of us struggle?
The biggest challenge is usually finding a fast, reliable hosting company.
We've all been through the nightmares - support take takes forever or doesn't resolve our problem always blaming something on your side...
But the biggest bummer is that the website always feels slow.
At CollectiveRay we host with InMotion hosting and our website is stupid fast. We run on a custom stack of LightSpeed server setup on MariaDB with a PHP7.4 engine and fronted through Cloudflare.
Combined with our front-end optimizations we reliably server 6000 users every single day, with peaks of 50+ simultaneous users.
Want to get a fast setup like ours? Transfer your site for free to InMotion hosting and get our 50% OFF on current pricing.
Frequently Asked Questions
Is there any risk in changing the upload_max_filesize directive?
Yes, there are a numbers of risks. The first risk is that any wrong small error in the .htaccess file will completely take down your site with a 500 server error and you will need to access and fix the file through your hosting server. There are other risks, but this is the one which most people can run into.
Why does this directive exist?
This directive exists to enable the web hosting server administrator to exert a level of control on the server, to ensure that the resources are shared fairly amongst users. By limiting access to certain resources, the administrattor can ensure that no single website or user is using a disproportionate amount of resources such as server space, or server memory. Such extensive use of resources could be done both intentionally or through server compromises or hacks.
What is upload_max_filesize?
The upload_max_filesize directive is a command which allows a website or web hosting to limit the maximum size of a single uploaded file. The similar directive post_max_size is a similar directive which specifies how large the POST data in an HTTP response that is used to send any kind of data to a server (not just limited to file size).
To check if your modifications are working, you can go back to upload the files your were trying to upload to see if the new maximum upload limit reflects the amount you set in your php.ini code. If all goes well, you can see the new value and you're going to be able to upload the file (such as an image in a gallery) that gave you trouble.
Finally, if nothing you've done is working and your host's support can't help for whatever reason, you can still upload the file as a workaround via FTP. FTP has no limitations and allows you to upload everything from pictures to plugins and themes. You can also upload files in bulk if you need them.
Please leave a useful comment with your thoughts, then share this on your Facebook group(s) who would find this useful and let's reap the benefits together. Thank you for sharing and being nice!
Disclosure: This page may contain links to external sites for products which we love and wholeheartedly recommend. If you buy products we suggest, we may earn a referral fee. Such fees do not influence our recommendations and we do not accept payments for positive reviews.