Upload Large Files in PHP with .htaccess
Wednesday, April 1, 2009 5:21I regularly hear few of my friends expressing their agony they face when they try to upload large files with php using HTML Forms. I tell them about .htaccess files, and they really enjoy the solution.
Many hosting providers limit the file upload size from 2 MB to 8MB and it is really a big problem when you need to upload large files (a video file of 10 MB). You know you can change the limit from php.ini but alas you are not allowed to modify the php.ini in your server. So what is the work around? Yes, the .htaccess file. You can change the upload limit with your .htaccess file. Create a .htacess file with following contents. Yes, you can include your declarations too.
php_value upload_max_filesize 30M
php_value post_max_size 30M
php_value max_execution_time 180
php_value max_input_time 180
With this value set in your .htaccess file, you have increased the upload limit to 30 MB. Also, you can change the maximum execution time for yor php script too. You will need this as the upload will itself take long time
Upload the new .htaccess to your webserver root folder. and you are ready to go. Now you will be able to upload large files from your HTML forms. Set the value as needed but wisely. Don’t let a script take all the resources.
Happy reading!
















