Page 1 of 1

WordPress – Increase Maximum Upload Size for Media Library File

WordPress – Increase Maximum Upload Size for Media Library File
   0

My latest issue with WordPress has been the limited maximum Media Library Upload Size when I tried uploading a few videos for an Arduino article.

In this article I’ll show you several methods to increase the Maximum Upload Size for the WordPress Media Library, either by modifying php.ini, functions.php or the .htaccess file. WordPress MU/Multisite/MS use will be addressed as well.




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.phpwp-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).

Donation options


Donations are very much appreciated, but not required. Donations will be used for web-hosting expenses, project hardware or a motivational boost (a drink or snack). Thank you very much for those have donated already! It's truly AwEsOmE to see that folks like our articles and small applications.

Comments


There are no comments yet.
You can post your own comments by using the form below, or reply to existing comments by using the "Reply" button.



Your Comment …

Friendly request to not post large files here (like source codes, log files or config files). Please use the Forum for that purpose.

Please share:
*
*
Notify me about new comments (email).
       You can also use your RSS reader to track comments.


Tweaking4All uses the free Gravatar service for Avatar display.
Tweaking4All will never share your email address with others.