When uploading files to WordPress you may come across a limit to the size of the file you can upload.
This is usually set by your web hosting company and more often than not it will be a low limit to discourage people from uploading huge files and therefore saving hosting space and money.
But what if you need to upload a file that is larger than the maximum upload file size?
Increasing the maximum upload file size
There are three changes that you can put in place that should result in increasing the maximum upload file size.
The reason I say “should” increase, is that some web hosting companies can place a hard limit on the upload size and you can talk to them until you’re blue in the face and they will not chance their minds.
For those that do offer this option, and it’s worth giving it a go anyway, here’s how to do it.
From the image above, you can see that the maximum upload file size is set to 2MB when trying to add an image to a WordPress post. We’re going to increase this to 64MB.
Updating your php.ini file
You will need to locate a file named php.ini in your WordPress installation folder on the web server. If the file does not exist, create a new empty file.
Edit the php.ini file and add the following new lines, taking care not to modify any existing lines which may be important to your website configuration:
upload_max_filesize = 64M post_max_size = 64M
Save the php.ini file and upload it to your web server, if working on a local copy, overwriting the server copy.
Now upload/insert a new file on your WordPress post to bring up the same media dialog box as before and see if this has increased the maximum upload file size to 64MB.
Hopefully the file size has now increased and you’re almost done.
If you don’t see any changes then log out and back into the CMS. Try to upload/insert a new file and see if the limit has now changed.
If the limit has still not changed then it may be that your web hosting provider just doesn’t allow you to manually increase this limit or that they have disabled user php.ini files.
Contact them directly, explaining what you are trying to do and see if they can point you in the right direction.
There is another step that you’re probably going to have to do at some stage so why not now.
By increasing the file upload size, php will need more memory to process the larger file.
If the php memory limit is not high enough this can cause php to generate an error similar to this:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home/xxx/public_html/wp-includes/plugin.php on line xxx
Increasing the WordPress PHP Memory Limit
To resolve this issue, we’re going to increase the php memory limit in WordPress to 64MB.
This should be ample size to allow processing of your larger file uploads.
In your WordPress installation folder, locate and edit the file wp-config.php.
Add the following new lines, taking care not to modify any existing lines which are important to your WordPress configuration:
/** New memory limit */ define('WP_MEMORY_LIMIT', '64M');
Save the wp-config.php file and upload it to your web server, if working on a local copy, overwriting the server copy.
Your WordPress installation should now be configured to upload and process files up to 64MB in size.