How to increase the Maximum Upload Size for the WordPress Media Library
So far I have found these methods to increase the maximum upload size for the WordPress Media Library (in preferred order):
If you have full access to your web-server, then I’d say all 3 methods can be considered “easy”, although finding the proper php.ini
file can be a pain.
Some of us do NOT have full access and for those the php.ini
method, or even the .htaccess
method might not work.
Watch those Web-host Limitations
Some web-hosts, specially in a shared setting, have put certain file size and storage limitations in place which, and no matter what you try, they cannot be overridden.
In that case none of these methods might work. Check with your provider in case you run into that situation.
WordPress Multisite Users
If you’re running WordPress MU (standard included with WordPress and referred to as WordPress MultiSite or WordPress MS ) should NOT forget to look under the Network settings on the Network Admin page: “Setting” “Network Setting” “Upload Settings” “Max upload file size“.
If you do not modify the maximum file size here, none of these methods will make a difference.
Modifying php.ini
For those without experience or limited access to their website: this method can be considered a last resort (just before FTP upload).
You will need to find the correct php.ini
file (the configuration file for PHP), and even if you have full access, this still can be a challenge.
Find the following “parameters” in the ini file (or add them if they do not exist)
1 2 3
| upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300 |
This example sets the maximum post (the HTML POST, a method for submitting data, not to be confused with the WordPress “post”) and the maximum upload size that PHP can handle to 64 Mb … you can of course modify this to the size you need. I use a rule of thumb to not go too crazy here and pick what you really need. For very large files I often resort to making the needed change, uploading the exceptional large file and undo-ing the changes so I’m back to the old settings.
The max_execution_time makes it that you buy your server a little more time for the upload process – the bigger the file, the longer it will take. Keep in mind though that this not just influences the upload time, but the general execution time of a PHP file, so if something goes wrong and your time is high, then it can take quite a while before PHP errors-out. A consequence of this might be undesired system loads!
Tip : If you’re unsure about what and how to do this, consider that most Web-Host providers are often very willing to assist you with this!
Modifying functions.php
If you have access to your theme files (doesn’t matter where you got the theme from, standard, 3rd party or homebrew), then the following method might be a simple one to implement.
Tip : The functions.php
file can be found in wp-content/themes/<your theme name>
.
Add the following lines to the functions.php
file of your theme:
1 2 3
| @ini_set( 'upload_max_size' , '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'max_execution_time', '300' ); |
This example sets the maximum post (the HTML POST, a method for submitting data, not to be confused with the WordPress “post”) and the maximum upload size that PHP can handle to 64 Mb … you can of course modify this to the size you need. I use a rule of thumb to not go too crazy here and pick what you really need. For very large files I often resort to making the needed change, uploading the exceptional large file and undo-ing the changes so I’m back to the old settings.
The max_execution_time makes it that you buy your server a little more time for the upload process – the bigger the file, the longer it will take. Keep in mind though that this not just influences the upload time, but the general execution time of a PHP file, so if something goes wrong and your time is high, then it can take quite a while before PHP errors-out. A consequence of this might be undesired system loads!
Note that these lines need to be placed in between <?php
and >?
, easiest way to make sure this goes alright, is to paste this code in the line right after the first <?php
you see in your functions.php
file.
Modifying .htaccess
Let me first say that I’m not a fan of modifying the .htaccess
file, the main reason for that is that .htaccess
can be difficult and even confusing to read – a recipe for errors that can be avoided.
Tip : If you really cannot resort to the previous two methods, then consider pasting the following code at the end of your .htaccess
file.
Tip : The .htaccess
file can often be found in the www directory (or public_html) of your website. This is the same directory where you’ll find your WordPress files like index.php
, wp-config.php
, and the folder wp-dontent
.
Add the following lines to .htaccess
:
1 2 3 4
| php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300 |
This example sets the maximum post (the HTML POST, a method for submitting data, not to be confused with the WordPress “post”) and the maximum upload size that PHP can handle to 64 Mb … you can of course modify this to the size you need. I use a rule of thumb to not go too crazy here and pick what you really need. For very large files I often resort to making the needed change, uploading the exceptional large file and undo-ing the changes so I’m back to the old settings.
The max_execution_time makes it that you buy your server a little more time for the upload process – the bigger the file, the longer it will take. Keep in mind though that this not just influences the upload time, but the general execution time of a PHP file, so if something goes wrong and your time is high, then it can take quite a while before PHP errors-out. A consequence of this might be undesired system loads!
Last Resort: Manual FTP Upload
In case none of these methods work, and you actually do have the needed storage space, then you could consider uploading the file (image, video, etc.) via FTP.
I personally do not like this method, since you’re working yourself around WordPress’s way of managing media, but in desperate situation it will work.
Step 1 – Upload the file with FTP
For this you will need an FTP client, like the free Filezilla (available for Windows, MacOS X and Linux).
Connect to your webserver and find a suitable location to store the file. Just make sure it’s located in the www
or public_html
directory, or a sub-directory of it. I would, if I had to, copy the file in the wp-content/uploads
directory so it starys with my WordPress setup.
After uploading the file, make sure to take note of the file location.
For example, say you uploaded the file “largevideo.mov” to wp-content/uploads
, and say your website is http://www.example.com, then your newly uploaded file can be accesses with “http://www.example.com/wp-content/uploads/largevideo.mov“.
Step 2 – Add content to your WordPress post
Adding this type of content strongly depends on the type of file you’ve uploaded. For now I’ll assume it is either an archive (ZIP for example) or a video file (MOV for example).
WordPress does not know about this file, so the Media Library will be of no help and we will need to add it manually.
An archive could be added as a download, like so (in the “Text” view of a WordPress post):
<a href="http://www.example.com/wp-content/uploads/largezipfile.zip">Download the ZIP file</a>
A video file could be added using shortcodes, which WordPress standard supports and enables a tiny media player at the same time:
[video width="800" height="600" mov="http://www.example.com/wp-content/uploads/largevideo.mov"][/video]
For more details about the video-shortcode, see the WordPress Codex on Video Shortcode.
Tip : If your web-host does not provide enough storage space, or your file is large than what they allow, then consider storing the file on a different server or service like for example DropBox – at this moment they will play only the first 15 minutes of a video and you can store only 2Gb max by default, so keep that in mind. You will need to copy the file in the public folder (see Dropbox documentation).
Comments
There are 2 comments. You can read them below.
You can post your own comments by using the form below, or reply to existing comments by using the "Reply" button.
I am not finding PHP.ini file in root directory as I have also selected “Showhidden files” option but still the PHP.ini file is not visible. I have seen another guide WordPress upload limit to resolve my issue but there is the same thing shows selecting hidden files will visible the PHP.inifile. Can you please tell me what should I do now whether I create a new file?
Amanda
The location of php.ini depends on your server configuration, and some providers won’t even allow you to edit it.
The easiest way to find the file is by creating an empty plain text file with this as content:
Save the file, for example to the root folder of your WordPress setup, naming it for example “phpinfo.php“.
Say your website is http://www.example.com, and you did place the config file in the root, calling it phpinfo.php, then you can open it in a browser like so:
This will show the configuration info and version of the PHP version used on your server.
Look for the line “Loaded configuration file” which should show the full path where the php.ini can be found.
You could also temporary install one of the many phpinfo WordPress plugins, for example this one or this one.
Keep in mind that, depending on yoru provider, the php.ini may or may not be accessible.
There are 3 alternatives to increase the upload size, that may or may not work;
1. in .htaccess (in the root of your WordPress setup);
Add something like this the .htaccess file (see above):
2. in cPanel (if your server uses this):
Depending on your setup, there may be an option to change the settings in PHP or in MulitPHP.
3. Change setting in the WordPress config file (wp-config.php) by adding:
hans