Anyone Can Code

Not everyone is a coder, but a coder can come from anywhere

How to upload large files in PHP

Posted by jhalak on May 15, 2008

Problem: File upload error (the uploaded file exceeds the upload_max_filesize directive in php.ini)

Solution:

1) To update the php.ini file set

upload_max_filesize = 20M (your desired size)

post_max_size = 20M (your desired size)

max_execution_time = 3000 (your desired time)

2) Add the following lines in the .htaccess file in the root directory of the server:

php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200

3) In the php file including the following codes:

<?php ini_set(“memory_limit”,”64M”); ?>
<?php ini_set(“post_max_size”,”20M”); ?>
<?php ini_set(“upload_max_filesize”,”20M”); ?>

In HTML file from where the file will be uploaded:

<form ……………………….>

<input type=”hidden” name=”MAX_FILE_SIZE” value=”200000000″>

<input type=”file” …………………>

</form>
The choice depends upon the situation.

2 Responses to “How to upload large files in PHP”

  1. Jason said

    thanks, very helpful, much apprciated.

  2. joe said

    ok good

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>