This question already has an answer here:
Please tell me there is a tag <input name = "upload []" type = "file" multiple = "multiple" />
How to make a php condition if input has a file. Thanks.
</div>
Somthing like this would do the trick
<?php
if(isset($_FILES['upload']['tmp_name']))
{
// Number of uploaded files
$num_files = count($_FILES['upload']['tmp_name']);
/** loop through the array of files ***/
for($i=0; $i < $num_files;$i++)
{
// check if there is a file in the array
if(!is_uploaded_file($_FILES['upload']['tmp_name'][$i]))
{
$messages[] = 'No file uploaded';
}
else
{
// copy the file to the specified dir
if(@copy($_FILES['upload']['tmp_name'][$i],$upload_dir.'/'.$_FILES['upload']['name'][$i]))
{
/*** give praise and thanks to the php gods ***/
$messages[] = $_FILES['upload']['name'][$i].' uploaded';
}
else
{
/*** an error message ***/
$messages[] = 'Uploading '.$_FILES['upload']['name'][$i].' Failed';
}
}
}
}
?>