Upload Large files using .htaccess in PHP

Hello Friends !!

In PHP, on server somekind of error occures when you upload large files.

If you work on localhost then you can change four parameters in php.ini file.

These four parameters are :

upload_max_filesize
post_max_size
max_execution_time
max_input_time

You can check these values using phpinfo.

But hou can you change php.ini on server ?

One trick you can do for large file upload. You can set this parameter in .htaccess and upload it.

The code is:

php_value upload_max_filesize 50M
php_value post_max_size 50M
php_value max_execution_time 500
php_value max_input_time 500

Now you can upload the file-size up-to 50MB in a simple way using file field in your html form and move_uploaded_file() function available in PHP. In the above .htaccess file, uploading capability is increased by the four parameter first one is maximum file size for uploading, second one is maximum size of the post data , third one is maximum time in seconds a script is allowed to run before it is terminated by the parser and last one is maximum time in seconds a script is allowed to parse input data such as like file uploads, POST and GET data.

You can change the above parameter to upload the bigger file size than 50MB.

So using this trick, you can upload large files on server.

  • arsid

    thanks am posted your link in my blog for more references

  • test

    ur code is not correct…