Uploading large files via PHP
Gary Oosterhuis | October 21, 2012
It happens time and time again. We develope a new website on our development server and take it live. A few days later we receive complains that file uploads aren’t working. After some investigation we quickly realize that the maximum upload file size set in PHP is only 2 MB. Why so low? The 2 MB limit is the default limit set when PHP is installed. Most hosts don’t bother to increase this limit until someone complains.
Quite often, you can increase this limit yourself. There are number of values that should be changed in PHP. One refers to the max upload size, another refers to the max post size and the others refers to the maximum time a PHP file takes to execute. Keep in mind that the process of uploading a file really involves calling a new PHP file. During the call to hte new PHP file you’re also uploading your document. This increase the time it takes to execute the PHP file based on the amount of time it takes to upload a file.
Some servers allow you to add the following code to the .htaccess file in the website’s root folder:
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200
Other servers require you to create a php.ini file in the root folder OR in the folder(s) that accept PHP file uploads:
Other hosts such as IX Web Hosting require that the php.ini file mentioned above be stored in the cgi-bin folder.
Link Web Development is a Barrie Website Design and Development company committed to providing quality websites to business owners and other Graphic Design Firms and SEO Experts.
Add a Comment