I have just put together the below code and would like to allow multiple image uploads. How would I go about this? A loop?
function upload($image, $dest, $tmp_name, $prefix, $height, $width) {
$path = $dest . $image;
$prod_img_thumb = $dest . 'thumbs/' . $prefix . $image;
if (move_uploaded_file($tmp_name, $path)) {
chmod ($path, 0755);
$destimg=ImageCreateTrueColor($height,$width)
or die('Problem In Creating image');
$srcimg=ImageCreateFromJPEG($path)
or die('Problem In opening Source Image');
if(function_exists('imagecopyresampled')) {
imagecopyresampled($destimg,$srcimg,0,0,0,0,$width,$height,ImageSX($srcimg),ImageSY($srcimg))
or die('Problem In resizing');
} else {
Imagecopyresized($destimg,$srcimg,0,0,0,0,$width,$height,ImageSX($srcimg),ImageSY($srcimg))
or die('Problem In resizing');
}
ImageJPEG($destimg,$prod_img_thumb,100)
or die('Problem In saving');
imagedestroy($destimg);
} else {
die('Error in moving uploaded file.');
}
}