How to Fix The Error File Exceeds the upload_max ?

0

 exceeds the upload_maxA fairly common problem that we often encounter in the WordPress community is that large images, themes, and plugins are not loaded into WP.

The error appears: “the maximum size of the downloaded files for this site has been exceeded.”

Today I will show you how you can increase your download limit in WordPress.

How to fix the error file exceeds the upload_max_ and increase the size of uploaded files in WordPress

The essence of the problem



Why is this happening at all? It is important to understand that this is usually not related to the WordPress system itself.

In most cases, the maximum size of downloadable files is set at the server level, from which it also follows that you cannot deal with this problem from WP.

This limit is set for security and maximum efficiency. Users will not be able to “fill up” your site with large video files, which would lead to a decrease in server performance.

I think this is a fully justified measure, but the standard limit of 2 MB (which stands on many servers) limits us too much, so let’s see how we can raise it.

Increase maximum download size

There are three main ways to help you deal with this problem.

I will start with the two most simple ones, after which I will turn to manually changing the server settings – there are also a lot of options for this.

Increasing the maximum download limit in a multisite assembly

If you have multisite installed, you can control the limit of downloadable files in the Settings-> Network Settings section.

Please note that this option will not override the server settings. If the server has a limit of 5 MB, and you install 10 MB in the admin area, the limit will still be 5 MB.

If the server has a limit of 20 MB, and your network settings are set at 1,500 KB, you can solve this issue by increasing the limit to 20,000 KB.

Contact your hosting company

Many hosting companies offer support that can help you in some situations.

Increasing the download limit is a trivial task for any person from technical support; he can do it within a couple of minutes.

Change server settings

There are plenty of server options that affect how the uploaded files will be processed.

Unfortunately, in many manuals, this is misunderstood – in them a lot of everything is changing.

According to the PHP documentation, three directives play an important role in this issue:

  • post_max_size
  • upload_max_filesize
  • memory_limit

 

The documentation also gives us fairly clear instructions on how they should be configured:

post_max_size sets the maximum size of data allowed for records. This option also affects file uploads. To upload large files, this value must exceed upload_max_filesize.

If the memory limit is available in your configuration script, the memory_limit may also affect file loading. In general, the memory_limit must exceed post_max_size.

We will need to set all these three parameters to allow the loading of our file sizes. If the largest file is 10 MB in size.

Then I recommend setting upload_max_filesize to 12M, post_max_size to 13M, and memory_limit to 15M.



Downloads may contain some textual information along with the file itself, so it is always better to leave some extra space for maneuvers.

Now that we know what needs to be changed, we need to learn how to do it. You can try three options. Some may not work for you, depending on your server settings.

Create or edit php.ini

By default, the php.ini files contain your server settings.

Due to some server restrictions, php.ini files may not be available, and therefore the method with .htaccess is usually used, which we will discuss later.

Go to the root directory of your site and open or create a file php.ini. If this file already exists, find three parameters and edit them if necessary.

If you have just created a file, or the parameters are not found, you can paste the code below into it:

  • upload_max_filesize = 12M
  • post_max_size = 13M
  • memory_limit = 15M

Create or edit.htaccess

A .htaccess file is a special hidden file that contains various parameters used to change server behavior.

If the php.ini method did not work, I recommend that you try the .htaccess method.

Using FTP or SSH connection, go to your root directory and see if there is a .htaccess file in it.

If it is, you can edit this file manually by adding the necessary code to increase the download limit.

  • php_value upload_max_filesize 12M
  • php_value post_max_size 13M
  • php_value memory_limit 15M

We use the PHP function ini_set ()

I am not a fan of this approach; however, if all else fails, you can try this method. Add the following code to your wp-config.php file:

  • @ini_set( ‘upload_max_size’ , ’12M’ );
  • @ini_set( ‘post_max_size’, ’13M’);
  • @ini_set( ‘memory_limit’, ’15M’ );

In theory, you can try to add this code to the functions.php of your theme or to the main file of your plugins, but usually, this code is not contained there.

Nginx setup

Nginx is an alternative to the good old Apache.

It can work many times faster than Apache, and for this reason, many highly specialized hosting use it on their servers to present pages.

If you run your site on Nginx, you will also need to change your php.ini file and Nginx config.

We have already talked about how to configure php.ini, so now we will provide the code for the Nginx config:

  • http {
  • client_max_body_size 13m;
  • }

There can be many different parameters in the http group, but we only change client_max_body_size.

Last but not least, you will need to restart some services to make sure that the changes have been applied. Run the following commands:

  • service php5-fpm restart
  • service nginx reload

Conclusion

It is very easy to check if the methods work. I like this way: just go to the Media section and click on the Add New link.



You should see a small message that reads: “Maximum upload file size: 8Mb” (“Maximum upload size: 8Mb).

The numeric value should change as soon as you specify new parameters.

I recommend that you undo all the changes that did not work.

The .htaccess and php.ini files work like cascading in CSS. The post_max_size value specified in the child category will overwrite the same directive in the parent category.

Leave A Reply

Your email address will not be published.