Having Trouble Uploading Large Files to your WordPress Media?
Recently asked by a client could I upload a larger than usual PDF for them. Sure I said, no problem. But there was! Da Da DAHHHHH!!
Anyone who is familiar with WordPress probably knows what is going to happen.
You can see at the bottom that your upload limit for any kind of file is 2MB.
Sometimes, you just need more!
Being what I thought was very clever I went to my server hosting. Here I used the upload function to place the file in the correct folder for the media.
I’m afraid not! WordPress still did not recognise the file as it was still too large. I would have to do things the hard way.
The first method I tried for uploading large files was to go to my functions.php file and add this code.
@ini_set( ‘upload_max_size’ , ’64M’);
@ini_set( ‘post_max_size’ , ’64M’);
@ini_set( ‘max_execution_time’ , ‘300’);
If it works, you can now upload files up to a size of 64MB. Depends on your theme. My client’s website didn’t allow it!
I added the below code to the .htaccess :
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300
The third method I tried for uploading large files is this. You need to add some code to your php.ini file. If your website does not already have one you can use FileZilla and Notepad++ to create one. The code you need to add is:
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
So what did I do?
WordPress has thousands of plugins and after failing to get the increased size for the media I went and had a look at some of them.
I found this plugin – Add from Server. It allows you to place larger files into your Media section if they are already in your server backend.
I had already placed the file there earlier ( as I mentioned ). It was simply a matter of using the new ‘Add from Server‘ section that had appeared under media and I was easily able to use the larger file.
For those whose hosting doesn’t let them easily upload a file, by using FileZilla you can place a file in the correct section for this to work.
So What Do I Recommend?
Obviously, use the plugin from the start! While the code is a better solution if it works, you know the plugin will work right from the start. When time is an issue just use the plugin.
Also, you are much more unlikely to damage your website with the plugin.
A Word of Warning
This post is aimed mainly at web developers. It is also good for amateurs so long as they remember the main rule.
Q: What’s the Main Rule?
A: Always make a backup of your website before you start!!!
This is a very good one to keep in mind. More than likely you are going to need to upload an image or a file that exceeds the 2MB limit. Remember this post when that happens.
If you don’t feel up to it yourself you can always contact us to do it for you. We are very affordable and we get the job done quickly and correctly.