I have this bit if code to upload an image
<input type='file' name='file1' id='file1'>
if($_FILES['file1']['error'] > 0){
die('An error ocurred when uploading.');
}
if(($_FILES['file1']['type'] != 'image/png') && ($_FILES['file1']['type'] != 'image/gif') && ($_FILES['file1']['type'] != 'image/jpeg') && ($_FILES['file1']['type'] != 'image/bmp'))
{
die('Unsupported filetype uploaded.');
}
if($_FILES['file1']['size'] > 102400){
die('File uploaded exceeds maximum upload size.');
}
$now = time();
while(file_exists($uploadFilename = 'uploads/'.$now.'-'.$_FILES['file1']['name']))
{
$now++;
}
if(!move_uploaded_file($_FILES['file1']['tmp_name'], $uploadFilename)){
die('Error uploading file - check destination is writeable.');
}
But i’d like to upload an array of images also, but am confused as what is the best way to do it if I simply make this change
<input type='file' name='image[]' id='file1'>
I really want to understand this process, so I gather I first need to check if an image has even been uploaded
if (!empty($_FILES['image'][]['name'])) {
then use a foreach statement to run code on each upload
//I really am confused at this point
Thanks…