Reply to Re: Database tmp name?

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

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