How to fix the “the uploaded file exceeds the upload_max_filesize directive in php ini” error

by

It can be very frustrating to run into any error on your WordPress site. But the “the uploaded file exceeds the upload_max_filesize directive in php ini” error can be hard to work around if you don’t know how. 

This message comes up whenever you’re uploading large files.  Things like images, videos, themes, plugins, and other WordPress files that can be very large. When they are too big, this error code tells you that you need to cut them down a bit. Usually, this means losing valuable content, which is a huge drawback for your brand. 

But not anymore. By the end of this article, you will know how to fix the “the uploaded file exceeds the upload_max_filesize directive in PHP ini” error in WordPress. That way, you can publish your content and move on to the next task. 

The best part is, the fix is much more simple than you might think. All you have to do is extend the server’s default upload limit. But don’t worry, we’ll tell you exactly what to do. 

TL;DR: Use a backup plugin before you make any changes or try to upload your work on your WordPress site. That way you don’t lose any of your work. You can instantly restore a previous version so you don’t have to start over. After you restore your saved backup, use the steps outlined below to fix the upload_max_filesize.

What is the “the uploaded file exceeds the upload_max_filesize directive in php ini” error?

The uploaded file exceeds the upload_max_filesize directive in php ini is an error code that shows up sometimes when uploading large files to WordPress. It means that the file you are trying to upload is too big according to what your server allows. But this doesn’t mean that you can’t ever upload your file to WordPress. All you have to do is change the limits according to your needs. 

the uploaded file exceeds the upload_max_filesize directive in php ini error notification

You can look at the current maximum upload file size in three different ways. 

To check the max upload size in WordPress, go to Media > Add New. You’ll see a message displayed at the bottom that tells you exactly the maximum file size.

Maximum upload file size data
Image source

Another way to check the max file size is with the Site Health Info tool. Navigate down to the Media Handling dropdown. Here you’ll find the Max file size value.

Site Health info
Image source

You can also find this info in the Server dropdown menu in the Site Health Info tool. You’ll find out how large your files can be next to Upload max filesize.

Server data in site health info
Image source

These limits on how large your uploaded files can be are set by your web hosting provider. You may need to upgrade to a different plan or ask your web host to change these limits for you. 

Fortunately, some web hosts allow their users to override these limits. (More on that in a minute.)

What is the cause for the uploaded file exceeds the upload_max_filesize directive in php.ini error

So why does this error happen anyway? Why don’t web hosts just let you upload whatever file size you want?

Web hosts are in charge of distributing their server resources to many websites at one time. Setting a limit on how much of this space each user has access to helps in two ways. First, it helps preserve resources for other users. And second, this helps keep the server running fast and smoothly. Everyone benefits from these file size limits most of the time. But it is very annoying whenever you’re trying to upload fresh content. 

The maximum file size is defined by the upload_max_filesize directive. You can find it in the php.ini file. That’s where the second part of the error message “uploaded file exceeds the upload_max_filesize directive in php ini.”

Since the web host (not WordPress) has set specific limits for how large each uploaded file can be, you can only upload files that fall below that limit. For example, if you try to upload a file that is 130 MB and your upload_max_filesize is set to 128 MB, you will receive the error message. 

How to fix the “the uploaded file exceeds the upload_max_filesize directive in php ini” error message

There are several ways to stop getting “the uploaded file exceeds the upload_max_filesize directive in php ini” error in WordPress. It’s super annoying to run into this every time you attempt to upload new content. You might try to work around it. But problems occur when users try to reduce the file size. And in some cases, that file or webpage is gone forever. Unless you have a backup, of course. 

Before we go into detail about six different ways that you can increase your file size limit on WordPress, let’s get serious. It’s important to have a backup of all your files to prevent data loss in case something goes wrong. Accidents happen, and sometimes trying to fix an error can cause damage or loss to your content. 

To prevent this nightmare from happening, you should make a backup of your WordPress website before you try any of the tips in this article. How? The best solution for this is BlogVault. It’s simple to use because you can migrate an entire website in minutes with no manual effort. And BlogVault monitors all changes that happen to your website. Plus, it helps debug any problems with your website. 

Now, here are six strategies to fix the “the uploaded file exceeds the upload_max_filesize directive in php ini” in WordPress:

Edit or create phpini via FTP

Changing the php.ini file will override your server settings, including the upload_max_filesize. Since this is the source of the problem, then this strategy can help fix the error. 

  1. Locate the php.ini file from your root folder. 
php.ini file
Image source

  1. Next, connect to your website with an FTP client
  2. Open the php.ini file (make a backup) and then locate upload_max_filesize = 128M by right clicking php.ini. (Move on to step 5 if it doesn’t exist)
editing php.ini file
Image source

  1. Change the value to the appropriate file size for your needs. 
  2. If you don’t have an existing php.ini file, you’ll need to create a new one from the root folder. 
creating new php.ini file
Image source

  1. Now, edit the php.ini file you created and add this code:

upload_max_filesize = 128M

  1. Save your changes and upload via FTP when you’re finished.

Since this is the file that is included in the uploaded file exceeds the upload_max_filesize directive in php ini error code, then it should be a quick fix! The success of this strategy depends on your web host’s settings, though. If you don’t have access to this file, then you should try to edit the .htaccess instead. 

Edit .htaccess

The .htaccess file lets you control the configuration for your web server. While some hosts do not allow users access, many do. If your web hosts allows it, you can edit the .htaccess file to increase your maximum upload file size. It’s a fairly simple way to fix this uploading error. But it’s a very important file, so be cautious before making any changes. 

Here’s how to change the upload_max_filesize directive via .htaccess:

  1. Find the .htaccess file through your hosting provider’s File Manager, or via FTP. 
Editing .htaccess
Image source

  1. Next, open the .htaccess file with a code editor, or edit directly from the File Manager.
  2. Then, add this code to the file (with the values you need to upload your file):

php_value upload_max_filesize 32M
php_value post_max_size 64M
php_value memory_limit 128M
php_value max_execution_time 300
php_value max_input_time 300

Each hosting provider may have a slightly different process, so if you’re having trouble locating the .htaccess file, contact your provider. 

As of May 2022, the top three web servers are Nginx (34%), Apache (32%), and Cloudflare (21%). If this trick doesn’t work, then you might need to try editing Nginx. Editing Nginx can be a little more complicated, so we recommend hiring a backend developer to help change your max file size. Freelance backend developers charge anywhere from $60 to $100 or more per hour for their work. 

Edit Nginx

If your WordPress site runs on Nginx, then fixing the uploaded file exceeds the upload_max_filesize directive in php ini error is a bit more complicated. You’ll need to edit the php.ini file and the nginx.config file

  1. Find the php.ini file at /etc/php/7.4/fpm/php.ini.
Image source

  1. Then add this code:

upload_max_filesize = 64M
post_max_size = 128M

  1. Use this code to save your changes:

sudo service php7.4-fpm restart 

  1. Find the nginx.conf file at /etc/nginx/nginx.conf or $ locate nginx.conf.
  2. Declare the client_max_body_size directive inside one of these blocks: the http {…} block, the server {…} block, or the location {…} block.

Here’s how to declare in the http {…} block:

http {

    …

    client_max_body_size 128M;

}

Here’s how to declare in the server {…} block:

server {

    …

    client_max_body_size 128M;

}

Here’s how to declare in the location {…} block:

location /files {

    …

    client_max_body_size 128M;

}

  1. Save and restart with this code and you’re done!

Edit phpini via Cpanel

If your web host uses cPanel, then you’re in luck! This might be the easiest strategy for increasing your max upload filesize. CPanel is a platform that many webhosts use to manage their server configurations. Some hosts allow their users access to cPanel, while others keep this strategy behind lock and key. In that case, you might need to call your hosting provider. 

You should have the ability to edit your upload_max_filesize directive in the php.ini file from the cPanel dashboard. 

  1. From the dashboard, go to Select PHP Version > PHP Options/Options. If that’s not available, then locate the MultiPHP INI Editor.
MultiPHP INI editor
Image source

  1. Next, select your WordPress site from the drop-down menu
  2. Now, find the upload_max_filesize directive and increase the value to meet your needs. 

Don’t forget to save! Ask your web hosting provider for specific instructions for increasing your upload_max_filesize directive in cPanel. 

Use a WordPress plugin to increase file upload size

Another method that you can use to increase the maximum file upload limit for your WordPress site is to use a plugin. That’s right. No code needed for this strategy. If you’re not totally comfortable writing code in WordPress, then this might be the best option to start with. 

  1. Install and activate the WP Increase Upload Filesize plugin

 

  1. Then, go to Media > Increase Upload Limit in your WordPress admin panel.
  2. In the dropdown next to Choose Maximum Upload File Size, select a more appropriate limit for your needs. 
  3. Save your changes when you’re done. 

Don’t forget! You are still limited by your web host, so only the available limits will be available to select. 

There are also several other plugins that you can use to help reduce your file size, including images, videos, and other specific elements. 

Contact host support

These strategies are all great ways to fix the uploaded file exceeds the upload_max_filesize directive in php ini error. But if you’re not great with code, or you’re having trouble figuring out how to change your file size settings, then you might need to call in the reinforcements. 

One of the perks of working with web hosting providers is that they offer round the clock support for their customers. Sometimes, it’s as easy as reaching out to your host and asking them to increase the max upload file size limit for you. It’s a very common request, so your hosting provider should have no problem helping you find a solution to upload the content you need. 

To check if your strategy worked, go back to Media > Add New from the WordPress dashboard. Take a look at your maximum upload limit at the bottom. Does it match the number you set? If your code was added correctly and your changes are properly saved, then you should see the value you entered in one of the methods above as your new max file size. 

Wrapping Up

Now you know the fix for the error “the uploaded file exceeds the upload_max_filesize directive in php ini.” Remember that if you’re still having trouble, your best option is to contact your web host. And don’t forget to have a backup of your WordPress database in case you lose all of your hard work trying to make your file fit within max_file_size limits. 

Having a great backup plan that allows you to schedule and automate your backups keeps your work safe without adding an extra step to your creative process. BlogVault offers real-time backups that are stored on their servers. Out of sight, out of mind, Sign up for BlogVault.

FAQs

Does WordPress have a max file size limit?

WordPress itself is not responsible for setting the max file limits for your website. Your max file size limit is set by your hosting provider. Typically each tier comes with increasing file size limits. However, each web host is a little different. If you’re working in WordPress, the maximum upload size falls somewhere between 2MB and 150MB depending on your web host’s settings. 

What is the maximum file uploading limit in PHP?

The maximum upload file size for PHP scripts is set to 128MB by default. But each web host provider dictates the max file size limits for their users based on speeds, availability, and pricing tier. You can check your maximum file uploading limit in PHP in WordPress. Go to Media > Add New. You’ll see a message displayed at the bottom that tells you exactly the maximum file size.

How do I increase the maximum upload file size?

There are several methods that creators can use to increase the maximum upload file size. WordPress allows users to increase the maximum upload size. But there’s a catch. Users can only increase the upload size as long as the web host allows it, too. In some cases, the only way to increase the maximum upload file size is to contact your web host support. But this article details how to increase the maximum upload file size by adding code to .htaccess, editing the WPconfig file, changing the php.ini via FTP, editing the php.ini through cPanel, or even using a WordPress plugin. 

How do I reduce file size for uploading?

If you’re out of options or you have a deadline to meet, you might choose to reduce the size of your file if you plan to upload it. Some content bears more weight on your website than others. The overall size of a web page includes everything that makes up the content of the page plus the files that create the page.
Start by getting rid of the photos and videos that you don’t need. Then, trim unnecessary code from your website by combining your site’s stylesheets and scripts. After that, you should reduce any unnecessary fonts. Using a content delivery network is a helpful tool to help reduce your upload size automatically. For things like images and videos, you’ll have to compress them with a tool like CSS Sprites.

Does reducing file size reduce quality?

It is a common misconception that reducing the file size has an effect on the quality of a photo, video, or web page. Reducing the file size does not have anything to do with the resolution. It’s all about reducing the amount of code that it takes to post your content on the web.

You may also like


WordPress Site Not Loading: 7 Easy Fixes
WordPress Site Not Loading: 7 Easy Fixes

You’ve probably experienced a small business’s website crashing during a Black Friday sale. Eager shoppers flood the site all at once causing it to become unresponsive. This is one of…

Solve: The Site Is Experiencing Technical Difficulties
Solve: The Site Is Experiencing Technical Difficulties

“The site is experiencing technical difficulties” error can feel frustrating. Just when you’re about to update a plugin or upgrade your PHP, this pesky problem appears. And sometimes, it locks…

How can we help you?

If you’re worried that your website has been hacked, MalCare can help you quickly fix the issue and secure your site to prevent future hacks.

My site is hacked – Help me clean it

Clean your site with MalCare’s AntiVirus solution within minutes. It will remove all malware from your complete site. Guaranteed.

Secure my WordPress Site from hackers

MalCare’s 7-Layer Security Offers Complete Protection for Your Website. 300,000+ Websites Trust MalCare for Total Defence from Attacks.