Increase PHP File Upload Size Limit

Hi Everyone…

I was working on final year project which was web based file manager. In that I was writing script to upload files. The problem i faced was that I can only

upload files of size <= 2MB. I changed the max file upload size in php.ini but it was useless and after lot of search i came to know about .htaccess and it solved my problem. Let me explain this step by step.

1. First of all make sure that your file upload controls allows you to upload files of you requirement. You can change the below highlighted value according to your requirment.

<form enctype=”multipart/form-data” action=”uploader.php” method=”POST”>
<input type=”hidden” name=”MAX_FILE_SIZE” value=”100000” />
Choose a file to upload: <input name=”uploadedfile” type=”file” /><br />
<input type=”submit” value=”Upload File” />
</form>

2. By default you can upload a file of max size 2M. To increase this open the file php.ini and look for the following lines.

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

and change the ‘2M’ to your required max size. Restart your apache server and go ahead.

3. If you don’t have access to php.ini file (may be because of shared webserver) or if above step doesn’t work then look for a file .htaccess and find the following lines.

RewriteEngine On
php_value upload_max_filesize 2M

again change the ‘2M’ to your required max size. Restart you apache server try your luck now though I was lucky after this step.. 😉

For very basic tutorial on file uploading see http://www.tizag.com/phpT/fileupload.php


Keep Smiling 🙂