class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
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());
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());