Hosting Coupon Code | 3 Months | 100% OFF Get Offer

How to Increase WordPress Max Upload File Size Limit

Moeez — August 6, 2019 5 Minutes Read
WordPress Maximum Upload File Size

By default, WordPress and your hosting provider limit the file upload size because of technical reasons. Users who need to upload files that exceed the pre-set limit often get an error and the operation fails.

The two most common reason why this problem occurs is due to file size upload restrictions added to the following two areas:

  • The upload_max_filesize directive in php.ini
  • Fatal error: Allowed memory size of xxxxx bytes exhausted (tried to allocate xxxxx bytes) in /home/your-username/public_html/wp-includes/plugin.php on line xxxx

There are multiple ways of increasing WordPress max upload file size limit. In this article, I will discuss just the most popular ways that have worked for the majority of the WordPress websites. But before diving into the discussion, I will discuss three variables that play important role in this problem.

  • Upload_max_filesize: This variable defines the maximum upload size of a single file.
  • Post_max_size: This variable defines the maximum upload limit for a POST request. Note that a single request could include multiple files.
  • Memory_limit: This variable defines the memory limit for a single script. This limit could be equal to or more than upload_max_filesize.

Note: There is a relationship between upload_max_filesize and post_max_size. In many cases, post_max_size is set at a higher value than the upload_max_filesize. For example, if you have several files of 5MB, and the upload_max_filesize is set to 5 MB and post_max_size is set to 20 MB then post_max_size cannot contain not more than 4 files.

Confirm the Default WordPress Max Upload File Size Limit

The default file upload size limit can be found by navigating to Media >> Add New.

As you could see from the following screenshot, the default maximum upload file size is set to 10MB.

In this tutorial, I will set the limit to 20MB. As discussed earlier, there are multiple ways of increasing the upload file size limit.

Let’s start:

1. Check with the Hosting Provider

Hosting providers who specialize in WordPress hosting has a default option for increasing the file upload size limit (often located right on the dashboard).

For instance, If you are a Cloudways customer, login to their platform, navigate to Servers tab and then Settings & Packages. In the UPLOAD SIZE field, enter the file size you wish. Once done, don’t forget to click the Save Changes button at the bottom of the page.

2. Modify (or Create) php.ini

php.ini (located in the root directory of the hosting account) is a configuration file that customizes the behavior of PHP at runtime. It contains a list of settings including maximum upload file size, maximum execution time, upload directory, global variables, and display errors.

Due to security concerns, almost all hosting providers keep it hidden. To access the file, login to the hosting account, navigate to the root directory and search for php.ini. You might need to mark “Show Hidden Files”. If there is no such file, create a new one with the name: “php.ini”. Make sure that the file includes the above three mentioned variables

Since I need to set the maximum file upload size to 20MB, I will change the values of upload_max_filesize to 20MB and post_max_size to 25 MB so that a single 20MB file can be used in the body of the post. The good practice is to set post_max_size more than the upload_max_filesize.

upload_max_filesize = 20M
post_max_size = 25M
memory_limit = 30M

Note: “M” refers to “MB”, memory_limit should be equal or greater than the upload_max_filesize. To be on the safe side, I have set it to 30 MB.

Note that some hosting providers rename the file to php5.ini.

3. Modify (or Create) .htaccess File

.htaccess is short for Hypertext Access, a configuration file used by Apache servers. Typically, it is located in the root directory. If the file isn’t there, create it with the exact filename and extension “.htaccess”

I assume you already have the file, copy and paste the following lines of code just below where it says #End WordPress.

Note: While searching for .htaccess, don’t forget to mark “Show Hidden Files”. It might be hidden by your hosting provider.

4. Modify WordPress Files

The above three methods are the most recommended ways of increasing the file upload size. However, for any reason, these methods don’t work, it is time to add to the WordPress files. Open up either wp-config.php or functions.php files, and paste the following lines of code:

5. Increase WordPress Max Upload File Size Through Plugin

If you’re not a fan of coding and working through the root access files, then you might be interested in this method to increase the upload size of WordPress.

The beauty of WordPress is that you will always find a plugin to solve the problem. If you do not want to do increase the file upload size manually, there is an excellent plugin named Increase Max Upload Filesize that will surely help you out. Just remember to enter the values in bytes (1024000 bytes = 1 MB). For 20 MB, multiply 1024000 with 20 and enter 20480000 in the textbox. Click Save Changes, and you are done!

Increase Maximum Upload File Size is a WordPress plugin that automatically detects WordPress upload limit and helps you increase the upload size of WordPress. All you have to do is install and activate the plugin…

Increase Maximum Upload File Size

Then navigate to the plugin on your WordPress admin panel sidebar

Admin Panel Sidebar

Once you are in the plugin settings, set your maximum upload file size limit and click save.

Increase Upload Limit in WordPress

Your new WordPress upload limit will be set.

If The Problem Persists…

There is a slight possibility that none of the above methods work for your website. In such cases, Don’t Panic. Contact your hosting provider and they will help you out!

Upload Files Via FTP

FTP comes handy when you need to upload large files. Note that files uploaded via FTP to /wp-content/uploads/ directory aren’t displayed in the media library. There is an excellent plugin Media from FTP that registers these files in the library in just a few clicks.

6. Increase WordPress Upload Limit in Multisite

If you are an agency running a multisite network, then you can increase your WordPress upload limit from your settings.

Navigate to your settings on your WordPress dashboard and set your WordPress upload limit.

Increase WordPress Upload Limit in Multisite

However, you cannot exceed your server size while you are setting your WordPress upload limit. If your server is 20gb, you cannot set the upload limit to 25gb.

Wrapping Up

If you think I have missed a popular method, feel free to mention it in the comments section below. If any of the mentioned methods worked for you, share the details in a comment.

Subscribe to Get a FREE WordPress Ebook Right in Your Inbox

WPblog provides the complete guide to launch your WordPress website completely FREE!

Moeez is ‘The’ blogger in charge of WPblog. He loves to interact and learn about WordPress with people in the WordPress community. Outside his work life, Moeez spends time hanging out with his friends, playing Xbox and watching football on the weekends. You can get in touch with him at moeez[at]wpblog.com.

THERE'S MORE TO READ

Newsletter