Multiple Image Upload Fails To Upload Only The First Image
Solution 1:
Look at your dump, and compare with your code.
Your code accesses ALL upload fields, even if there is no file uploaded, for example in fields 3, 4 and 5. So your code iterates over ALL these files and uses realpath()
on an empty string.
This will trigger the error message "Error.File not uploaded". Which is correct because file number 3, 4 and 5 were not uploaded, they were left empty.
Your code has to deal with this.
And as a security feature, do not use realpath()
, use is_uploaded_file()
. PHP has a list of filenames that were created during the upload, and only those files should be allowed to process in the upload script. You do not want to touch any other files, even if an attacker tricked PHP into manipulating the "tmp_name".
Solution 2:
"upload" here $_FILES['upload']
refers to the name of the file field in the form.
you are only ckecking if a file from the file field named upload has been uploaded
did you maybe name the first upload field in the form differently?
Solution 3:
Figured out my mistake.
I originally wrote
if(!is_dir($upload_path))
{
$upload_path=mkdir($upload_path,0644,true);
}
and i changed it to
if(!is_dir($upload_path))
{
mkdir($upload_path,0644,true);
}
Which solved the errors i was getting. Really stupid mistake on my part.
Post a Comment for "Multiple Image Upload Fails To Upload Only The First Image"