Welcome to Developer's Zone  
You are not Logged in! Log in to check New Updates.

Upload large(Big) files in PHP using .htaccess

(back)

There are three ways to do this task which are below.
    1) .htaccess
    2) php.ini
    3) httpd.conf

When you are working in localhost than you may change and increase the upload file size limit using any of the above. But the best way is to do with .htaccess as when your site will be on server than you may not have access of php.ini and httpd.conf. You can make .htaccess file , write the below rules and you will get the solution to increase the upload file size.

Below is the rules of htaccess using which you can use to upload a large file using file field of the form and copy() OR move_uploaded_file() function in PHP.
 

php_value upload_max_filesize 32M
php_value post_max_size 32M
php_value max_execution_time 360
php_value max_input_time 360

That's it. Now you can upload the file with size up-to 32MB.

In the above .htaccess rules,uploading capability is increased by above rules which are explained below.

    Rule 1: upload_max_filesize sets maximum file size for uploading.
    Rule 2: post_max_size sets maximum size of the post data.
    Rule 3: max_execution_time sets maximum time in seconds a script is allowed to run before it is terminated.
    Rule 4: max_input_time sets maximum time in seconds a script is allowed to parse input data of HTML form.

You can set the value of these parameters as per your file size.
You can also set these values from php.ini or httpd.conf file by searching these name and increase the size limit as per your needs.