How to Increase the WordPress Maximum Upload File Size
If you’re reading this, then you probably ran into an issue with uploading files to your WordPress site and are looking for a quick fix. This Error can be very frustrating, but rest assured it’s a common problem and can be easily fixed in 5 minutes. The reason why this error may appear is that many hosting providers keep this limit low by default. So in this article, I will provide you with some quick ways to resolve this issue and get back to uploading the files you need regardless of the size.
Let me first explain the technical concept behind it, so you can have a full understanding of the following steps. WordPress maximum upload file size is a server-level setting which also means that unfortunately, you can’t resolve it from within WordPress. This limitation in file upload exists for security purposes. It prevents users from flooding your site with huge video uploads and over load your server to a point where the website do down. I think that’s a great security measure from wordpress, specially that it allow you to change it as you will.
Increasing The WordPress Maximum Upload File Size
There are three basic ways to resolving this issue.
- Ask Your Hosting provider For Help
- Install upload max file size plugin
- Modify Server Settings
- Alternative Option – Upload Files Via FTP
-
Ask Your Hosting provider For Help
One of the fastest solutions is to reach out to your hosting support and ask for help. Many hosting companies have support which can help you out quickly in these situations. Increasing an upload limit is a simple task for a tech support person, and they should be able to do it within a minute. Other Hosting providers would require you to have a Managed WordPress account or a managed server so that they can perform this adjustment.
-
Install Uplaod max file size plugin
Increase max upload file size plugin, increase upload size limit up to 250Mb and up to 500Mb.
Step one: Download the plugin from Plugins>Add New>search>increase max upload file plugin
Step two: Navigate to the plugin setting and increase the Mb as you wish.
Step three: Check if Upload file size was successfully increased on Media page
-
Modify Server Settings
There are a lot of server settings that affect how uploads are handled in WordPress. If adding a plugin didn’t work, then you’ll need to modify the server setting manually. According to the PHP Documentation, the three directives that matter are:
- post_max_size
- upload_max_filesize
- memory_limit
The documentation also gives us pretty clear guidelines on how they should be set up:
[post_max_size] sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize. If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size.
We’ll need to modify these three directives to accommodate for our file sizes. If the largest file will be about 10 MB, I would recommend setting the upload_max_filesize to 12M (12 MB), the post_max_size to 13M and the memory_limit to 15M. Notice, they use M instead of MB. Uploads can contain a fair bit of text information in addition to the file itself.
Now that I have clarified what has to be modified, you just need to know how to modify it. There are five things you can try. Some of these may not work for you, depending on your server setup.
-
Change PHP Options in cPanel
If you are running on a host that uses cPanel, you can easily change this from the UI. Under Software click on “Select PHP Version.”
Click on “Switch to PHP Options.”
You can then click on each property and change its value. Then click on “Save.”
-
Create Or Modify php.ini Files
php.ini files are the ones that govern how your server is set up. Due to restrictions in servers, you may not be able to use php.ini files, which is why the .htaccess method works more consistently, we’ll take a look at that next. To edit your php.ini file, login to your site via FTP or SSH, go to your site’s root directory and open or create a php.ini file.
f the file was already there, search for the three settings and modify them if necessary. If you just created the file, or the settings are nowhere to be found you can paste the code below. You can modify of course the values to meet your needs.
upload_max_filesize = 12M
post_max_size = 13M
memory_limit = 15M
Some shared hosts might also require that you add the suPHP directive in your .htaccess file for the above php.ini file settings to work. To do this, edit your .htaccess file, also located at the root of your site, and add the following code towards the top of the file:
suPHP_ConfigPath /home/yourusername/public_html
-
Create Or Modify .user.ini Files
If the above didn’t work for you, it could be that your host has the global settings locked down and instead have it configured to utilize .user.ini files. To edit your .user.ini file, login to your site via FTP or SSH, go to your site’s root directory and open or create a .user.ini file. You can then paste in the following code:
upload_max_filesize = 12M
post_max_size = 13M
memory_limit = 15M
-
Create Or Modify .htaccess Files
The .htaccess file is a special hidden file that contains various settings you can use to modify the server behavior, right down to a directory specific level. If the php.ini method above didn’t work, we suggest you try this next. First of all, login to your site via FTP or SSH, take a look at your root directory and see if there is a .htaccess file there.
If there is you can edit that file to add the necessary code for increasing the upload limit.
php_value upload_max_filesize 12M
php_value post_max_size 13M
php_value memory_limit 15M
If you get an “internal server error” message with the method above it is most likely your server is running PHP in “CGI mode,” which means you can’t use the above commands in your .htaccess file.
-
Use The ini_set() PHP Function
The last option is not one we are fans of, but if all else fails you can give it a go. First, login to your site via FTP or SSH, and locate your wp-config.php file, which is typically in the root of your site.
Add the following code to the wp-config.php file:
@ini_set( 'upload_max_size' , '12M' );
@ini_set( 'post_max_size', '13M');
@ini_set( 'memory_limit', '15M' );
In theory, you could try adding it to your theme’s functions file or your plugins main file, but this code really has no place in either. As a last resort or an interim solution, it could work though.
NGINX Setup
NGINX is an alternative web server software to good old Apache. It can be a lot faster than Apache. If you are running your website on NGINX you’ll need to change your php.ini file as well as your NGINX config file.
We’ve already discussed how to modify a php.ini file so all we need is the code for the NGINX config:
http {
client_max_body_size 13m;
}
Note that you’ll have a number of settings within the HTTP group. Only change the client_max_body_size parameter to make sure you don’t modify anything unintentionally. Last but not least, you’ll need to reload some services to make sure the changes are applied. Issue the following commands and you should be all done:
service php5-fpm restart
service nginx reload
If you are a Kinsta client, you don’t have access to your NGINX config. So feel free to reach out to our support team and they can quickly make the changes for you.
-
Alternative Option – Upload Files Via FTP
If you tried all the above options and you are still struggling with your current hosting provider on getting your limits raised, remember that you always have the option to upload your large files via FTP (SFTP) . FTP is mainly used to upload a lot of large files to the server, this is actually a faster method. I hope this article was of value to you and helped you increase WordPress maximum upload file size limit.
Double Checking the Maximum Upload File Size
Checking if the above solutions worked based on you hosting provider is straight forward. Go to the Media section>Add New. You should see a little message that says: “Maximum upload file size: 250 MB” for example. As the beginning, we started with a 5 MB upload file size limit and as you can see below, we have now increased it to a 250 MB limit.
If you made changes to multiple places, I recommend working your steps backwards going step-by-step and undo any changes that didn’t work. Both the .htaccess file and php.ini file are similar to the cascading properties of CSS. The post_max_size set in a child directory overwrites the same directive from a parent directory. This can lead to a lot of confusion if you’ve defined these directives everywhere in an attempt you tired.
Tip: Disable WordPress from Creating Thumbnails if you are considering storage space. Here are Three helpful Ways to Disable WordPress from Creating Thumbnails