Here is the loop. See if that can help me more.
<?php
foreach ($_FILES["userfile"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
// Grabs everything before and after the last dot and turn it into the new filename.
$imgfile = $_FILES['userfile']['tmp_name'][$key];
$imgfile_name = $_FILES['userfile']['name'][$key];
$imgfile_size = $_FILES['userfile']['size'][$key];
$imgfile_type = $_FILES['userfile']['type'][$key];
$dir="/services/webpages/i/s/islandershuntclub.com/public/admin/uploads/";
srand((double)microtime()*1000000);
$unique_str = md5(rand(0,9999999));
$p = strrpos($imgfile_name, "." );
$old_name = substr($imgfile_name , 0 , $p ) . $unique_str . substr($imgfile_name , $p , ( strlen($imgfile_name ) - $p ) );
//-- RE-SIZING UPLOADED IMAGE
$src = imagecreatefromjpeg($imgfile);
// Capture the original size of the uploaded image
list($width,$height)=getimagesize($imgfile);
$newwidth=480;
$diff = $width / $newwidth;
//$newheight=($height/$width)*100;
$newheight= $height / $diff;
$tmp=imagecreatetruecolor($newwidth,$newheight);
// this line actually does the image resizing, copying from the original
// image into the $tmp image
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
/*== setup final file location and name ==*/
/*== change spaces to underscores in filename ==*/
$new_name = str_replace(" ","_",$old_name);
$newfile = $dir . "/$new_name";
$db_names[] = $new_name;
/*== do extra security check to prevent malicious abuse==*/
/*== move file to proper directory ==*/
if (!imagejpeg($tmp,$newfile,100))
{
/*== if an error occurs the file could not
be written, read or possibly does not exist ==*/
print "Error Uploading File.";
exit();
}
/*== delete the temporary uploaded file ==*/
unlink($imgfile);
imagedestroy($tmp);
imagedestroy($src);
$desc = $_POST['desc'];
$file = "/services/webpages/i/s/islandershuntclub.com/public/admin/pics.txt";
$fd = fopen ($file , "a");
fwrite ($fd , $new_name . ";".$desc."\n");
fclose($fd);
}
}
?>