Ask the community if you have any question about PHP,
MySQL, Apache and Linux for quick answers!!!

Increasing file upload limit in PHP

There are different options to increase file upload limit in PHP. First is changing PHP configuration file (php.ini) and restarting webserver or overwriting the php.ini value in .htacces (this option is available if you are running Apache).

There are 2 directives which affect upload limit i.e. upload_max_filesize and post_max_size.

Now we look at the first method. First you have to find out where the php.ini is. To find out the location, make a .php file containing only this code and place it in your webroot and point your browser to this file.

<?php phpinfo(); ?>

In the page output you can find Configuration File Path. Open this file and change the values for upload_max_filesize and post_max_size according to your requirement e.g. to set 10MB upload limit, the values will be
upload_max_filesize = 10M
post_max_size = 10M


After changing the values, save php.ini and restart the webserver. If you open up the above PHP file again, you'll see the updated values of upload_max_filesize and post_max_size.

In case you don't have access to php.ini (in shared hosting environment) or don't want to restart the webserver then the best option is to use .htaccess.

The syntax for .htaccess as follows
php_value upload_max_filesize 10M
php_value post_max_size 10M

You may need to tweak the following PHP configuration variables too while uploading larger files. These are max_input_time, max_execution_time and memory_limit. memory_limit should be larger than post_max_size.

Apache supports .htaccess. I am not sure if you can overwrite these settings in .htaccess with lighttpd.

If it is not working, let us know.

Still need help? Ask us

Related Posts

Leave a Comment