How to Increase upload_max_filesize WordPress

How to Increase upload_max_filesize WordPress

How to Increase upload_max_filesize WordPress - The upload size limit for WordPress is sometimes limited. Here's how to increase it.

How to Increase upload_max_filesize WordPress – The upload size limit for WordPress, which keeps your large files, plugins, and themes from being uploaded, is set to a low value.

If you have a site that emphasizes the use of media, this could be a serious challenge. In these situations, you must either increase the max upload size in WordPress or your server (or both) will be at risk.

If you’re hosting with a hosting provider and on a server, you’ll need to determine the way of solving this issue in order to accomplish your task.

We will be going over all of them in this article, and we’ll show you how to quickly increase the maximum upload size in WordPress.

Let’s get started!


The Largest File That You Can Upload to WordPress is 2 Gigabytes?

When you upload large files to a server, it uses up a lot of the server’s resources. Because users might put their site in danger by saturating a server’s resources, the default maximum upload size for WordPress typically ranges from 4 MB to 128 MB. In the vast majority of cases, the hosting provider establishes this limit at the server level.

By default, WordPress uses constant values that define this limit, but they cannot be overridden by the server-level settings in most cases.

To be absolutely sure, check your Media Library in your WordPress site. Just give it a try. Go ahead and upload a file that’s over the maximum upload file size limit. Error messages in the form of “Oops! This won’t work!” should appear.

The “exceeds the maximum upload size for this site” error can be frustrating, but it exists for two primary reasons: security and efficiency. The large file upload limit hinders site owners and other site users, including malicious actors, from uploading large files (e.g. high-resolution images, large videos).

Abandoning the XCache or Prefetch system could leave your server unable to function. That can result in your site becoming crippled. In even worse cases, it can bring your site down entirely!


Check the Current Maximum Upload Size in WordPress

1. Via the Media Library

The quickest way to see your current maximum upload size is to go to your WordPress dashboard, and then click on Media in the left-hand menu.

This will take you to the library page where you can then look at your site’s upload capacity. Once you have activated the media uploader tool, go ahead and click on the Add New button.

It’s possible that the monthly bandwidth limit will be different if you use a different web hosting provider.

A quick method is to use the “Media” option at the top of the window and choose “Add New.” The message will then appear at the bottom of the window.


2. Via the Site Health Info

The Site Health Info tool was added to help you troubleshoot your WordPress site better in the 5.2 update to the Site Health Info WordPress plugin. In this section, you will find most of the information about your server and WordPress configuration.

Either the server and WordPress will determine the maximum upload file size, or the maximum upload file size can be found in the following settings screen.

In the first place, you can locate it by checking under the Media Handling dropdown. There you will find the value of the constant for the maximum file size that can be uploaded.

The second method is to select the server option in the dropdown menu. This section features a variety of configuration options related to your webserver setup. You can use the dropdown to search for the value for Upload max filesize constant and view what it is. To complete this step, the maximum upload file size limit is 128 MB.

To see other PHP constants and their values, look under constants in the right column of the table.

  • PHP post max size: This defines the maximum upload limit for POST requests.
  • PHP memory limit: Specifies the amount of memory allocated for PHP. The Upload max filesize limit should be equal to or higher than the uploaded file size. If that is not done, the upload will fail.

You use your web host to manage your settings. On the majority of starter hosting plans, the upload size limit is likely to be lower than on enterprise hosting plans.

Sometimes, hosts allow you to set the limits to a higher value. However, in most cases, you will likely need the assistance of your hosting provider as well as a plan upgrade to be able to increase them.


Reasons to Increase the Maximum Upload File Size in WordPress

To expand on this, there are many different reasons why you may need to increase your WordPress site’s maximum upload file size. As can be seen from the list below, the most common issues are:

  • Installing a large WordPress theme or plugin through the dashboard in the admin area is something you want to avoid.
  • Getting on a schedule of updating your WordPress site regularly is a great way to keep your readers engaged and bring them back for more. In other words, uploading new images, videos, audios, and other media regularly is also part of that. While that is not always possible, there is a file size limit for uploads when this is the case.
  • If you want to use a large video or image as your site’s background or header, you must upload it to the server.
  • Your aim is to sell digital files such as ebooks, photographs, videos, themes, and plugins, which you will market directly from your site. Sometimes, these files can balloon up to hundreds of megabytes in size (or more).

Now that we’ve learned the basics of increasing the maximum upload file size in WordPress, let’s move on to how to do that.


10 Ways to Increase the upload_max_filesize WordPress

While there are many possible approaches to solving the WordPress upload size issue, your best bet is to find a workaround.

First, we’ll start with the ones that are the most straightforward. Then, we’ll work our way up to the intermediate-level tutorials.

1. Via .htaccess File on Apache Server

You can use an Apache webserver, so if you run your site on Apache, you can edit your WordPress site’s .htaccess file to increase the maximum upload size. The root directory of your WordPress site’s directory is where you’ll find your .htaccess file.

Three PHP directives, as listed in the PHP documentation, are said to be responsible for how WordPress handles uploads. To sum up, they are:

  • upload_max_filesize
  • post_max_size
  • memory_limit

The same point has already been discussed in the Site Health Info section above. If you were to adjust the values of these three directives to accept file sizes, that would be greatly beneficial. As an example, if you plan to upload the largest file that you will ever upload to be 32 MB, we recommend the following:

  • upload_max_filesize = 32M
  • post_max_size = 64M
  • memory_limit = 128M

Be sure to notice that all of the values used M instead of MB. To handle directives, PHP uses the “DEFINE” statement.

Additionally, an upload can include additional information, apart from the actual file. All other upload-related directives, including one-file-upload directives, need to be postponed for a while. You can learn more about how to improve PHP memory limit in WordPress by reading our detailed tutorial on how to do so.

If you use FTP or SFTP to access your .htaccess file, your hosting provider’s File Manager may also work.

Editor's Note:

Learn to use Filezilla to access your site directory via FTP connection:


Begin by making certain that you’ve placed the code for the .htaccess file into a text editor, such as Notepad. Once you’ve done that, add the following code:

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

In the above code, you can see that there are two other PHP directives: max execution time and max of input time. This tells us how long it takes for a server to complete a single PHP task. The greater your uploads, the longer it will take to complete the process. You should ensure that their values are set to a number that is appropriate for your use case.

A word of caution: If you try the instructions above, you may be presented with a 500 Internal Server Error. You are probably getting this error because your server is running PHP in CGI mode. Thus, in those cases, you will not be able to use the following directives in your .htaccess file.


2. PHP Options via cPanel

You can increase the max upload file size through the cPanel dashboard on your hosting provider’s server, if your hosting provider uses the cPanel dashboard to help you manage your server and site configuration.

As a first step, you must go to your cPanel dashboard and choose the Select PHP Version option from the Software section:

Select PHP Version cPanel

This tutorial page explains how to modify your server’s current PHP version and how to enable and disable numerous PHP extensions. Navigate to the PHP Options panel by clicking on the Options link in the navigation menu.

To make changes to the PHP configuration directives, such as the upload max filesize, post max size, memory limit, max-execution-time, and max-input-time settings, click the button beneath this text. The values you can configure in this section are dependent on your current hosting plan.

The company’s values call for transparency and total integrity in all communications. If you have any doubts about these values, we suggest you contact your hosting provider.

You don’t have to click anything because the latest cPanel dashboard saves all of your changes automatically. However, if you’re using an older cPanel version, it is extremely important that you click the Save Changes button.


3. Increase the Max Upload File Size in Nginx

Nginx is a popular and effective webserver, but it is also significantly more capable. In the majority of cases, Nginx can serve more concurrent requests than Apache, which translates to a better performance.

As Nginx is currently the web server of choice for running WordPress, you will have to edit both the php.ini and nginx.conf files. The file has already been handled in the past. An Nginx configuration file is also known as a Nginx config.

The php.ini file is located in the /etc/php/7.4/fpm/php.ini directory on a Nginx server. While PHP may have the same location no matter which version you have installed, the exact path can vary slightly.

upload_max_filesize = 64M
post_max_size = 128M

The memory limit can be specified in a configuration file, but it does not have to be for this particular configuration as Nginx handles memory allocation differently. If you want more information, there is an extensive Stack Overflow thread on the subject.

After saving your php.ini file, you can activate the configuration changes by restarting PHP-FPM using the following command in your terminal:

sudo service php7.4-fpm restart

Note that the code you see above might vary slightly depending on the PHP version that is installed on your server.

The next step is to set the new maximum upload size limit with Nginx’s client_max_body_size directive. In order to use this directive, you must declare it in the nginx.conf file, which is located at /etc/nginx/nginx.conf.

This directive can be defined inside of the http{…}, server{…}, or location{…} blocks.

To have an effect on all the sites and apps hosted on this server, make it a part of the http block:

http {
...
client_max_body_size 128M;
}

This setting should only be applied to the server block of a specific site or app that is hosted by this server:

server {
...
client_max_body_size 128M;
}

This location block only has an effect on the directory specified (i.e. files, uploads) in a website or app:

location /files {
...
client_max_body_size 128M;
}

It’s important to remember to save the file and restart Nginx so that the changes will be applied. To accomplish that, you can enter the following command in your terminal:

sudo service nginx reload

4. Coding Out Using WordPress ‘upload_size_limit’ Filter

In WordPress 2.5, a new filter was introduced called upload size limit, which restricts the maximum size of uploaded files in php.ini. This filter is employed in various places, like in the Media Library and Site Health Info screens, to show you the maximum upload size that you are allowed to use.

Here is an example of this filter in action, as featured on the blog of WordPress contributor Drew Jaynes. It is responsible for limiting the upload size for all non-admin roles:

/**
* Filter the upload size limit for non-administrators.
*
* @param string $size Upload size limit (in bytes).
* @return int (maybe) Filtered size limit.
*/
function explainwp_filter_site_upload_size_limit( $size ) {
// Set the upload size limit to 10 MB for users lacking the 'manage_options' capability.
if ( ! current_user_can( 'manage_options' ) ) {
// 10 MB.
$size = 1024 * 10000;
}
return $size;
}
add_filter( 'upload_size_limit', 'explainwp_filter_site_upload_size_limit', 20 );

The code in the above example uses WordPress’ manage options capability to set this limit only for non-administrators. If you want to target specific user roles or user IDs, you can modify the code. Check out our detailed article on WordPress job roles and capabilities for more information.


5. Increase upload_max_filesize WordPress Plugin

Making changes to code using SSH or FTP/SFTP is not suitable for everyone. Alternatively, you can use a WordPress plugin to write or edit code if you don’t enjoy doing it by hand.

Using the WP Maximum Upload File Size plugin, we will use these settings. As of the time this is being written, there is only one up-to-date plugin in the WordPress plugin repository that can help you with this.

[postembedexternal exurl=”https://wordpress.org/plugins/wp-maximum-upload-file-size/”]

In order to get started, you must first install and activate the WP Maximum Upload File Size plugin. Finally, make your way to the settings screen within your WordPress dashboard. For your convenience, you can see the maximum upload file size that both your hosting provider and WordPress have set.

By viewing the current uploaded file size on the WordPress screen, you can see that it is lower than the maximum permitted upload size of your hosting provider. And as a result, you can increase the maximum upload file size by selecting the Maximum Upload File Size option using the dropdown.

While it is not possible to have a max upload file size limit greater than the one set by your hosting provider using this plugin, you can accomplish this using your web host’s control panel. You will need to contact your hosting provider in order to take this step.


What If You Can’t Increase Max Upload File Size in WordPress?

If you have tried all those steps and still can’t increase the max upload file size in WordPress, now there are ways to anticipate it and solve your issues. Here’s the list of what you can try if this happens to you:

1. Contact Your Hosting Provider

While issues with uploading files and file size limits can result in restricted access, reaching out to your hosting provider for assistance may provide an immediate solution.

Although many hosting companies are skilled at expanding an upload limit, this task is trivial for tech support, which makes this a simple task for most hosting companies.

Trying to adjust or change your server or website configuration files can be an uphill battle every time. Since this is our recommendation, we always recommend you try this method first.

Most hosting providers have 24/7 support system so you can easily contact them whenever you’re in need.


2. Upload Files via FTP/SFTP

If you still struggle with all of the above, do you need help? Your hosting provider can help you raise the upload file size limit, or do you want to do it yourself? There is always an option to upload large files via FTP/SFTP.

The upload method that gives you the greatest transfer speed is best for you if you have many large files to upload. We have written a more in-depth tutorial on how to bulk upload files to the WordPress media library where you will find out everything you need to know.

Some times, WordPress does not recognize files uploaded via FTP/SFTP. If that is the case, you can use the free Add From Server plugin to import the uploaded files into WordPress.

Alternatively, you can go ahead and do the same from the command line, and it will import images for you via WP-CLI. With the wp media import command, you can use it to attach images from local files or URLs.

Follow the following video which is very easy to follow by the folks at WPBeginner:


Wrapping Up

In the case of increasing the maximum upload file size in WordPress, increasing the maximum upload file size is straightforward. Whatever the nature of your web presence, whether it’s an extensive portfolio site or a larger WordPress installation, all you have to do is know where to look and what command(s) or tool(s) to use.

If the provider isn’t a hosting company, you should be able to reach out to them. On the other hand, if you must remain with a difficult host, we’ve shown you some alternative methods you can try before making the switch to better hosting.

Now go ahead and upload your file!

ExplainWP
The WordPress Learning Hub

Related Posts