I think I might have figured out why the script dosen´t work. The array never stops it keeps going and when it cant find anymore it takes the last upload as empty and then my script tells me that I can´t upload an empty field.
I use another script now. This is the form script:
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input name="userfile[]" type="file" class="multi"/>
<input type="submit" value="Upload File" />
</form>
And this is the upload script:
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = 'uploads/';
$uploadfile = $uploaddir . basename($HTTP_POST_FILES['userfile[]']['name']);
echo "<pre>";
if (move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($HTTP_POST_FILES);
print "</pre>";
Now my question is if someone maybe knows how to make the script stop when it dont find anymore pictures to upload. Because I use a Javascript to upload multipe pictures but if I add 3 pictures my php script writes it as 4 and says that there is something wrong.
Please help me I have been workning with this problem for about 4 straight days now.