I'm not sure if this is a browser or PHP problem. I experimenting with file uploading and have encountered a strange problem.
Running Hiawatha with PHP under Puppy Linux. All working great. The whole site is php-driven.
I have implemented the example code from the PHP manual with minor mods. The below is copied from the actual
code I'm running. (There is no validation or safety code in place yet since I'm just experimenting locally.)
CLIENT:
<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="testuploadhandler.php" method="post">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<!-- Name of input element determines name in $_FILES array -->
<p>Select up to four files:<br>
<input name="audiofile[]" type="file"><br>
<input name="audiofile[]" type="file"><br>
<input name="audiofile[]" type="file"><br>
<input name="audiofile[]" type="file"><br>
<input value="Upload Files" type="submit"></p>
</form>
SERVER:
echo '<pre>';
foreach ($FILES["audiofile"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $FILES["audiofile"]["tmp_name"][$key];
$name = $_FILES["audiofile"]["name"][$key];
if( move_uploaded_file($tmp_name, "uploads/$name") ) {
echo "File: " . $name . " uploaded successfully.\n";
}
else {
echo "File: " . $name . " upload failed.\n";
}
}
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
RELEVANT PHP.INI SETTINGS:
file_uploads = Yes
upload_max_filesize = 600M
memory_limit = 8M
post_max_size = 8M
max_execution_time = 7200
max_input_time = 7200
The above code works fine for small files, a few kbytes. Multiple file upload works fine. But if I try to upload more than about 200k total,
it fails instantly and the browser throws a "connection interrupted while negotiating" error. Digging deeper I find that the
browser did invoke the php code but php throws an error at the foreach() saying the array is empty. Dumping
the array shows that it is indeed empty.
So it seems to me that the browser is messing up but I'm not sure. And if it is, i have no idea what's wrong.
I've run out of ideas.