To all those disbelievers — yes, uploading 1 GB or bigger files to WordPress is possible! :)
And you don’t have to play with some workarounds like uploading files through FTP and hard-linking them with your post. You can upload large file right in WordPress built-in file uploader.
However, a lot of steps may be needed before you will be able to achieve this.
First step is to set correct value in your blog’s settings:
You will find it either in your admin panel in Settings section, or if you own a blog network, you’ll have to go to Network Admin > Settings to find it.
- This option is visible and available only to users with admin privileges
- If you own a site inside blog network, but not the whole network then you can’t set this.
You must contact blog network admin and ask them to do the change.
The above setting is meaningless, if you’re PHP configuration is different. WordPress sets its own limit, but this is always overridden by PHP configuration. So, you must to set correct values for
Most of the guides say that you must have each value bigger than the following one, because each is related to entity or operation that adds itself a little bit or little more, i.e.:
upload_max_filesizesets the actual maximum limit of files you want to upload
post_max_sizedecides how big the POST body can be (it includes your file, headers and some more)
memory_limitsets maximum memory your PHP script can use, so must be way bigger than transferred data.
But, to be honest with you, I always ignore such advice and set all three to twice the value of the maximum file size that I expect to be uploaded. So, if I want to upload 0.5 GB files, I set all these three values to
Whichever way you’re going to choose, this doesn’t change the fact, that you will have to probably set it in many places, in order to achieve expected results.
Note that file upload-related settings are changeable at
PHP_INI_PERDIR level. Which means that you cannot set them using
ini_set() in your script! Or, actually, you can set them (your code won’t fail), but whatever you set there will be ignored. Follow here or here for more details.
This is the first place, you want to visit. If you have your PHP interpreter’s configuration exposed via hosting’s configuration then go ahead and set either desired or maximum allowed value.
As you can see above, in my case, maximum allowed value (in configuration) was at 10% of the value that I actually wanted to set. But, fortunately, it turned out that (at least at my hosting), I can set some nasty workarounds to override this.
Apache and PHP configuration
Now you have to force Apache and PHP to respect your changes, by changing their configuration files. As already explained above, the configuration entires that are in scope of our interest are set per folder which means that you have to upload corresponding files directly to the folder where your WordPress resides (i.e. the folder where you store your wp-config.php file).
For php.ini set values directly:
memory_limit = 1G upload_max_filesize = 1G post_max_size = 1G
For .htaccess file use
# BEGIN WordPress php_value memory_limit 1G php_value post_max_size 1G php_value upload_max_filesize 1G # END WordPress
You can use
1000M) to denote megabytes (MB) and
1G, as above) to denote gigabytes (GB). PHP will understand this. You can always use direct value to denote your limit in kilobytes, if you wish (so
1024000 in this case, as in WordPress configuration).
Of course, don’t overwrite these files, append these lines to the end of files instead.
If you’re done with that, but see no effect then this may mean that your hosting provider is one of those that don’t allow you to change values in php.ini.
At each step of your “journey” you should keep checking, if you’re going into the right direction, by checking the actual value of
upload_max_filesize respectively that your PHP’s configuration returns. PHP Info is your friend here.
The easiest way is to put:
<?php echo phpinfo(); ?>
to some file, copy it over FTP to any web-accessible folder in your hosting and fetching corresponding URL in your browser:
As you can see, in my case there are two values. First is overridden by me, in the way that I showed above. Second one is the value that I set in my cPanel for my hosting.
Refreshing WordPress Media Upload page can also act as above verification.
Depending on your specific situation you will have to set your maximum uploaded file size in any or all of these places:
In second and third case, remember that these must be copies of these files, placed in your WordPress root folder. Changing configuration in your main / general files (assuming that you have access to those) is pointless in this case.
Setting correct value in WordPress configuration (details) is required in every scenario.
You may ask “Why?”. Why to bother and visit all these places to set this value? Why simply transferring files via FTP and hard-linking them to post (as suggested in introduction) isn’t considered easier and faster?
Well… for sure easier and faster, but I had my reasons:
- I wanted to learn something new to reuse this knowledge in future.
- I needed to know, if I can beat by ISP / WordPress in limiting me! :)
There’s also third reason. But, it is weird, so I wanted to keep it to the very end.
I am purist. Due to WordPress construction only uploading a file directly to post can assign that file upload with that particular post. When browsing Media Library, you can set media filter to “Unattached”:
I don’t want to see too many files there! :) I want all / most of them to be attached to corresponding posts.