Database tmp name?

See all posts See thread Reply

Re: Database tmp name? new!
by David, 14 years ago
Thank you for prompt reply; this is my very first attempt at anything like this. It currently looks like this? Is it something obvious I have missed or is this just wrong? Where would I attach the $foo? Your help is greatly appreciated.

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) {
      echo 'OK';
    } else {
      echo 'Error: ' . $handle->error;
    }
  } else {
    echo 'Error: ' . $handle->error;
  }
  unset($handle);
}    

// now, you have all your picture names in $uploaded
// do your database insert like this for instance
$sql = "INSERT INTO photos2 (my_field1, my_field2, my_field3, my_field4) ";
$sql .= "VALUES ('".$my_field[0]."', '".$my_field[1]."', '".$my_field[2]."', '".$my_field[3]."')";
$x = mysql_query($sql) or die(mysql_error());
Reply
Re: Database tmp name? new!
by colin, 14 years ago
You need to save the image names in the database where it says echo 'OK';. There, you can do your SQL query. But in your SQL, you use $handle->file_dst_pathname for instance.Reply