Edit .htaccess to increase PHP’s max file upload

Tue, Apr 8, 2008

Programming & Code


To increase the upload file size limit on your website, you need to edit PHP’s configuration settings. Unfortunately, not everyone has their own web server, so most of the time people are constrained by the limits of shared hosting. But you can still modify your base php.ini file by creating your own php.ini with the edits that you want.

Your php.ini file needs to be in every folder that’s going to be affected, or at least in the folder where the php script is being called from. Unfortunately if you have dozens of folders that need this edit, then you’ll need dozens of php.ini files.

An alternative is to then use .htaccess. By just placing a.htaccess file in your root folder, all folders beneath it will also have the change. The code to change your PHP max file upload size is:

RewriteEngine On
php_value post_max_size 1000M
php_value upload_max_filesize 1000M
php_value max_execution_time 6000000

You can edit it to suit your needs. 1000M = 1GB, so edit accordingly. Do note that your host will need to allow PHP edits though.

Similar Posts:

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , , , , , , , , ,

This post was written by:

- Alvin is a Singaporean who's interested in marketing, techy stuff and likes to just figure out how the two can work with each other. On top of his blog, you can also follow him on Twitter.

Get Alvin's Report On How To Blog Successfully - Free!

7 Comments For This Post

  1. adi wirawan Says:

    thanks very helpfull my friend

  2. mary Says:

    I get error internal server error when doing this things.

  3. faress Says:

    tankyou my friend you are the legend
    very tanks
    best wishes

  4. Lee Says:

    Cool. I’m going to try this out on the rackspace cloud.

  5. Ichha Says:

    Same error

  6. Roch Says:

    Do you know of anyway with htaccess to disable someone from using your domain to point to their own website on the same server? Ex: they use YOURDOMAIN.com to promote their PHISHING WEBSITE.COM by using this simple URL to send users : YOURDOMAIN.COM/~phishing/file.html

    Any help would be greatly appreciated. Thanks

  7. Alvin Poh Says:

    Do you know the URL in question? if you do, sounds like you could use a redirect command, like so: RedirectTemp /~phishing/file.html http://www.yourdomain.com

2 Trackbacks For This Post

  1. problem z rozmiarem zalacznikow Says:

    [...] dziaÅ‚a dla tych którzy maja problem jak ja Edit .htaccess to increase PHP’s max file upload | Alvin Poh's Blog pozdrawiam Odpowiedź z Cytatem   + Odpowiedz na ten temat [...]

  2. Increase the maximum php file upload size » Kay's Web Dev Project Journal - Things I'm discovering along the way for my Web Development Diploma during 2010. Says:

    [...] M can be changed to GB as required. Information source URL: http://www.alvinpoh.com Posted in Ramblings | Tagged php Cancel [...]

Leave a Reply

*