Reply to Re: Database tmp name?

Re: Database tmp name? new!
by David, 14 years ago
Ok. It is now filling the name in correctly on the database, however I am uploading 4 and its inserting the same name in the 4 fields?

My code...

include('class.upload.php');

$files = array();
foreach ($_FILES['my_field'] as $k => $l) {
 foreach ($l as $i => $v) {
 if (!array_key_exists($i, $files))
   $files[$i] = array();
   $files[$i][$k] = $v;
 }
}      
foreach ($files as $file) {
  $handle = new Upload($file);
  if ($handle->uploaded) {
    $handle->Process("./");
    if ($handle->processed) {

      // it is only here you know that your upload has succeeded
      // so you can insert the filename in your database here
      $sql = "INSERT INTO photos2 (my_field1, my_field2, my_field3, my_field4) ";
      $sql .= "VALUES ('".mysql_real_escape_string($handle->file_dst_pathname)."', '".mysql_real_escape_string($handle->file_dst_pathname)."', '".mysql_real_escape_string($handle->file_dst_pathname)."', '".mysql_real_escape_string($handle->file_dst_pathname)."')";
      $x = mysql_query($sql) or die(mysql_error());
      
    } else {
      echo 'Error: ' . $handle->error;
    }
  } else {
    echo 'Error: ' . $handle->error;
  }
  unset($handle);
}
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