How to change the PHP Upload Limit

by Jay Versluis

in PHP

Usually your hosting package limits the amout of data you can upload to 2MB, which isn’t enough for most of us. It’s good for that 200k photo, but say you’re uploading a 4MB audio clip, a video or a large PDF, you’re stuck.

Fret not my friends, for help is at hand! Put the following code in your .htaccess file and smoke it:

php_value upload_max_filesize 100M
php_value post_max_size 100M

Instead of “100M” you can choose any limit you like, say 5M, 10M or whatever limit you like.

If you can’t find the .htaccess file, it might either be that

  • your FTP client doesn’t display hidden files; make sure that it does
  • or it doesn’t exist (in which case, create a plain text file, upload it and name it .htaccess)

If you’re having trouble, just download this file. Then simply unZIP it and upload the contents into your WordPress directory. Once it’s on the server, rename it to .htaccess and you’re done.

Good luck ;-)

{ 23 comments… read them below or add one }

Jimmy Cracked Corn July 13, 2009 at 9:15 pm

Thank you. This worked great for me today on a WP install on a Mosso/Rackspace account.

Reply

Tom S August 23, 2010 at 5:40 pm

Doesn't work for me. If I insert those lines in the dot-htaccess file, WP doesn't work at all (gives me a Bad Configuration Error). Any ideas?

Inside the dot-htaccess file are these lines already. I put your code at the bottom (under the last # END Wordpress comment):

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Reply

Jay Versluis August 24, 2010 at 8:22 pm

Hi Tom,

sorry to hear that. I'd put the php_value statements at the very top of that file.

The current contents makes it possible for Wordpress to use "pretty permalinks". If all else fails, delete everything in the .htaccss file, make the file writeable and add the php_value statements I've given you. Then go back to Settings – Permalinks in Wordpress to update the rewrite structure.

Good luck ;-)

Reply

Steven September 14, 2010 at 3:42 pm

500 Internal Server Error
"The server encountered an internal error or misconfiguration and was unable to complete your request."

.htaccess has full permissions (777), the two lines are right on top and I can't get to Settings – Permalinks to update the rewrite structure because I can't get to anything at all with the error.

Reply

Jay Versluis September 14, 2010 at 7:27 pm

Steven,

depending on the text editor and FTP Client you're using, the file can get screwed up.

I've uploaded this sample .htaccess file to get you started. UnZIP it, upload it to your server, then rename it .htaccess and change the file permissions to 777 for the permalink structure. That'll eliminate any errors that may have happened during the editing of that file.

If that doesn't work, it must be your FTP client. Make sure it's using BINARY mode when uploading files to your server.

Hope this helps ;-)

Reply

chris September 21, 2010 at 7:08 am

Worked a treat… After trying several solutions this worked 'out of the box'. Thanks

Reply

Jay Versluis September 21, 2010 at 9:49 am

Great, glad to hear it ;-)

Reply

Frank Solis November 10, 2010 at 8:05 am

Hi Jay,
I've tried each of the various methods you describe above to try and get the htaccess file to work, but I'm having the same trouble that Tom S describes above. I finally downloaded your sample.htaccess file and uploaded, then renamed it–but I get the same error. Hmmm. On another, separate thread elsewhere I see a similar kind of workaround being employed on the php.ini file: I tried all of those as well–I don't get the errors, but it doesn't change the 8MB maximum upload limit. This is very frustrating, as I have a client who needs to upload a large audio file and we can't do it.

Reply

Jay Versluis November 10, 2010 at 1:11 pm

Tricky one. Let me see if I get this right: without any .htaccess file, all is well but your upload limit is 2MB (or the default PHP Upload Limit) correct? And when you amend the .htaccess file as I suggested or upload my sample file, all you get is a 500 internal server error, right?

Then the only explanation that makes sense is that the FTP client is screwing it up. Or, your server does not run Apache as a web server.

There's one other way you can add the file and the settings if you have SSH access to your server. Are you running your own server?

I can always do this for you if you get stuck: http://wpguru.co.uk/support/server-maintenance/ch

Reply

Andy November 11, 2010 at 12:15 pm

Hey,

Thanks for the info. worked a treat on my Wordpress site.

Andy

Reply

alex79 December 9, 2010 at 2:52 pm

its worked great for me. thanks

Reply

Chris October 27, 2011 at 11:00 am

Thanks! Been trawling through answers to this question for ages, all to no avail – and this worked instantly. Brilliant.

Reply

Jay Versluis October 27, 2011 at 11:14 am

You’re very welcome! Loving the sound of that ;-)

Reply

Thomas Hedin November 3, 2011 at 2:49 am

Where exactly would I add that to my .htaccess

Below is what is in there at the moment. How should it look after I add the code?

Thank you so much.

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Reply

Jay Versluis November 3, 2011 at 3:49 am

Hi Thomas,

Those are the WordPress rewrite rules for Pretty Permalinks, make sure you don’t erase those. Add the other code at the very top of the file (before #BEGIN WordPress) and you should be golden.

Hope this helps ;-)

Reply

Thomas Hedin November 3, 2011 at 4:36 am

Strange,

I gave it a try, but it causes an internal server error.

I wrote the host, and hopefully I’ll hear back soon.

Reply

Jay Versluis November 3, 2011 at 2:54 pm

Some hosts won’t allow you to override this, however it should not cause an internal server error.

Some FTP clients screw this file up when you upload it, you can test this by downloading the file again and having a look in your text editor. It could also be your text editor – make sure you DO NOT USE Word or Pages for this, it has to be Notepad, Write or Text Edit. Your FTP client needs to transfer this file in ASCII.

Reply

Joe White November 8, 2011 at 6:31 pm

Yes, I followed the same instructions, but got the following when I tried to load my website:

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@joewhitenoise.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Any thoughts?

best,
Joe

Reply

Jay Versluis November 8, 2011 at 6:39 pm

I’m afraid not Joe,

other that what I’ve already said in a previous comment. Some hosts don’t allow .htaccess overrides so that could be an issue. And make sure that your FTP client uploads the file correctly (you can check by downloading the file again and comparing it to the text file). Also, don’t use Word or Pages to edit the file – it has to be a plain text editor (like Notepad under Windows or Text Edit in Mac).

I’d say get in touch with your hosting company and ask them to be 100% sure.

Reply

Leave a Comment


Notify me of followup comments via e-mail. You can also subscribe without commenting.

Next post: