Increase Maximum PHP Upload Size

Many shared hosts put very low restrictions on the size of the files that can be uploaded through PHP. But, many hosts also allow you to create your own php.ini file in the root directory of your site. This file can override some of the servers default PHP settings. If not already done simply create a php.ini file and place in the public_html directory of your site. If the server is configured correctly, after inserting this snippet the servers default max upload will be overridden. For this example it was changed to 20 megabytes.

; Maximum file size of post data that PHP will accept.
post_max_size = 20M

; Maximum allowed file size for uploaded files.
upload_max_filesize = 20M

Or you may need to preface with php_value:

php_value upload_max_filesize 100M
php_value post_max_size 100M


  1. User Avatar
    Permalink to comment#

    You can see what’s your current limit by using the ini_get function:

    Note that ini_set can’t be used to modify the max size of the upload files because the file info is sent before ini_set is executed.


  2. User Avatar
    Permalink to comment#

    I am on a shared host (fused network). There default php max upload size is 12 mega bytes. After using this snippet I have successfully uploaded uploaded files through my site (running on Drupal) larger than twelve megs. Seems to work for me.

  3. User Avatar

    Hm, I hope this is not considered as cheating.

  4. User Avatar
    Ashley Michèlle
    Permalink to comment#

    I am working on a client’s site, and an unable to use the .htaccess without getting a 500 error… what am I doing wrong?


    • User Avatar
      Permalink to comment#

      Most probably you are making mistake in regular expression (if any).

      Can’t say in details unless you can post some code here.

  5. User Avatar
    Mohsin Khan

    what is limit for upload_max_filesize ?

  6. User Avatar
    miracle chigaro
    Permalink to comment#

    @ Mohsin Khan

    You just need to configure the maximum if u are uploading documents like pdf, images, doc, xls just configure it to 2048

  7. User Avatar
    Ahmed Ali
    Permalink to comment#

    Hi there,
    When i add this configuration into my server it gives me the 500 server error.
    I m using this snippet

    php_value upload_max_filesize 20M
    php_value post_max_size 20M

    into my .htaccess file.
    Can you explain what is going wrong with this.

    Thanks in advance.

Leave a Comment

Posting Code!

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.