Page 1 of 1

*SOLVED* Large File Upload

Posted: Tue Apr 08, 2008 3:52 am
by mchaggis
Hi,

Not sure if this is the correct place, but it seems to me to be...

I have an upload script which is working for smaller files, but weirdness occurs with large files.

When I upload files of 5Mb it works a treat, but if I try and upload a 16Mb file, it sits there for a while and then just re-presents the blank form. Look at the logs, it doesn't seem clear as to whether it has actually contacted the server or not. Usually when I upload files that are over the allowed limit I get an error, but this just reloads the upload form? I going to continue to try and debug, but was hoping that other people may have come across this weirdness?

Snippet from php.ini

Code: Select all

 
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
 
; Whether to allow HTTP file uploads.
file_uploads = On
 
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =
 
; Maximum allowed size for uploaded files.
upload_max_filesize = 50M
 
Snippet of the form:

Code: Select all

 
<form id="upload" name="upload" method="post" enctype="multipart/form-data" action="/media/action.php">
<input type="file" name="MediaFile" id="uploadMediaFile" name="MediaFile" />
    Max. file size ~<?=ini_get('upload_max_filesize')?>
</form>
 
Snippet of the action.php script:

Code: Select all

 
<?php
print_r($_FILES);
?>
 
Uploading a smaller file results:

Code: Select all

 
Array ( [MediaFile] => Array ( [name] => 3.7Mb.mp3 [type] => application/x-crossover-mp3 [tmp_name] => /tmp/phpAEG0Gk [error] => 0 [size] => 3796323 ) ) 
 

*SOLVED* Re: Large File Upload

Posted: Tue Apr 08, 2008 4:06 am
by mchaggis
Ok... Just a quick update. After posting this topic, I decided to go right back to basics and create a file called testaction.php just containing:

Code: Select all

 
<?php
print_r($_FILES);
phpinfo();
?>
 
The result of this was that it did actually load this page, but with no $_POST or $_FILES data... But I came to also notice that there was a php.ini configuration line:

Code: Select all

 
; Maximum size of POST data that PHP will accept.
post_max_size = 8M
 
I have changed this to:

Code: Select all

 
; Maximum size of POST data that PHP will accept.
post_max_size = 58M
 
(upload_max_filesize+the default 8M post_max_size

And guess what... It all works a treat... I am guessing that post_max_size is a new ini setting for PHP5. Just be warned if you are moving from PHP4 to PHP5 that you will need to increase post_max_filesize to be larger that upload_max_filesize.