larger file upload problem with php

Posted by chris on Stack Overflow See other posts from Stack Overflow or by chris
Published on 2010-04-15T11:54:04Z Indexed on 2010/04/15 12:43 UTC
Read the original article Hit count: 231

Filed under:
|
|

I need to upload a csv file to a server. works fine for smaller files but when the file is 3-6 meg its not working.

$allowedExtensions = array("csv");
         foreach ($_FILES as $file) { 
            if ($file['tmp_name'] > '') { 
             if (!in_array(end(explode(".", strtolower($file['name']))), $allowedExtensions)) { 

              die($file['name'].' is an invalid file type!<br/>'. '<a href="javascript:history.go(-1);">'. '&lt;&lt Go Back</a>'); 

             }
             if (move_uploaded_file($file['tmp_name'], $uploadfile)) {
                    echo "File is valid, and was successfully uploaded.\n";
                } else {
                    echo "Possible file upload attack!\n";
              }

             echo "File has been uploaded";



            } 

//upload form

 <form name="upload" enctype="multipart/form-data" action="<? echo $_SERVER['php_self'];?>?action=upload_process" method="POST">
                    <!-- MAX_FILE_SIZE must precede the file input field -->
                    <input type="hidden" name="MAX_FILE_SIZE" value="31457280" />
                    <!-- Name of input element determines name in $_FILES array -->
                    Send this file: <input name="userfile" type="file" />
                    <input type="submit" value="Send File" />
            </form>

I have also added this to htaccess

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

Where am i going wrong?

© Stack Overflow or respective owner

Related posts about php

Related posts about file-upload