Increase PHP’s File Upload Settings with .htaccess

From time to time the need comes up to increase the maximum file upload size for a website. For reference, what I’m referring to is uploading media files (pictures, PDFs, data files, etc.) through an HTML web form.

Typically PHP comes configured to allow a 2 Meg upload size. Some web hosting companies allow you to make these changes directly in the PHP.ini file. In that case you open your PHP.ini file and simply look for “upload_max_filesize”, “post_max_size”, and “memory_limit” and make the appropriate changes.

If no PHP.ini file is available through your hosting platform an alternative method for adjusting this would be to add the following three lines to your .htaccess file.

php_value  upload_max_filesize  8M
php_value  post_max_size  16M
php_value  memory_limit  24M 

Some notes:

Keep in mind that extra large files will take longer to upload so you’ll want to make sure that your scripts do not time out when uploading. This will be a trial-and-error process based most likely on your client’s Internet connection speeds.