Reply to Re: multiple files upload

Re: multiple files upload new!
by colin, 16 years, 9 months ago
This is not a problem with the class! Please check your SQL query.

Even if some images are not uploaded, you are still updating the database! You always update the three image fields in your query.

This code below:
$mpic[1]=", pic1='".$msc0.$uploaded[0]['large']."'";
$mpic[2]=", pic2='".$msc1.$uploaded[1]['large']."'";
$mpic[3]=", pic3='".$msc2.$uploaded[2]['large']."'";
Should be something like:
if (array_key_exists(0, $uploaded)) 
  $mpic[1]=", pic1='".$msc0.$uploaded[0]['large']."'";
if (array_key_exists(1, $uploaded)) 
  $mpic[2]=", pic2='".$msc1.$uploaded[1]['large']."'";
if (array_key_exists(2, $uploaded)) 
  $mpic[3]=", pic3='".$msc2.$uploaded[2]['large']."'";
So that you are updating ONLY the fields which have an image uploaded.

Note that you will also have to change this line
$uploaded[] = $this_upload;
into something like:
$n++; 
$uploaded[$n] = $this_upload;
so that each picture from $_FILES has proper key.

Please contact me privately should you want more information. This is a basic PHP/MySQL problem, and has nothing to do with this forum.Reply

Your reply

Name *
Email 
Title *
Text *
CAPTCHA image
Enter the code displayed on the image:
Click on the image to generate another one if it is hard to read it. The case is important