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 }

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

Joe White November 8, 2011 at 6:46 pm

Thanks, Jay. I’m a bit confused as to why such a limit would be imposed. I’m using Wordpress through a hosting service with unlimited (theoretically) memory. I basically just want the option of embedding MP3 and video files without having to link to something like Soundcloud (whose visual interface I don’t like.)

Any other options for how to get around this 8 mb limit?

best,
Joe

Reply

Jay Versluis November 8, 2011 at 8:08 pm

I’m sure you hosting company can increase this for you – if not via .htaccess then maybe there’s another way. Having said that, shared hosting is a finely tuned ecosystem so I do understand that they want to keep the caps on how much RAM each user can use. Who are you hosting with? Unlimited is probably referring to disk space rather than system memory ;-)

You can upload larger files via FTP and then link to them manually. It’s not as convenient as uploading them from the WordPress backend, but works with files as large as your web space allows. Search for FileZilla, that’s a free FTP client. Upload your files to wp-content/uploads for example and access them like this: http;//yourdomain.com/wp-content/yourfile.mp3

Hope this helps ;-)

Reply

Dan December 8, 2011 at 10:32 pm

Thank you Jay! I’ve been searching the internet for a solution. Editing the .htaccess file did not work for me either (I got the internal error message). I don’t know why I did not think to just upload it via an FTP program, but this makes perfect sense!

Reply

Jay Versluis December 13, 2011 at 5:33 pm

I’m glad it helped ;-)

Reply

Leave a Comment

Next post: