Я внес некоторые изменения в ваш код, используйте его. Может помочь вам, а также, пожалуйста, отметьте
<input type="file" multiple>
if(isset($_FILES["photo"]) && $_FILES["photo"]["error"] == 0){
$allowed = array("jpg" => "image/jpg", "jpeg" => "image/jpeg", "gif" => "image/gif", "png" => "image/png");
$countfiles = count($_FILES['photo']['name']);
for($i=0;$i<$countfiles;$i++){
$filename = $_FILES["photo"]["name"][$i];
$filetype = $_FILES["photo"]["type"][$i];
$filesize = $_FILES["photo"]["size"][$i];
// Verify file extension
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if(!array_key_exists($ext, $allowed)) die("Error: Please select a valid file format.");
// Verify file size - 20MB maximum
$maxsize = 20 * 1024 * 1024;
if($filesize > $maxsize) die("Error: File size is larger than the allowed limit.");
// Verify MYME type of the file
if(in_array($filetype, $allowed)){
// Check whether file exists before uploading it
if(file_exists("upload/" . $filename)){
echo $filename . " is already exists.";
} else{
move_uploaded_file($_FILES["photo"]["tmp_name"][$i], "upload/" . $filename);
echo "Your file was uploaded successfully.";
}
} else{
echo "Error: There was a problem uploading your file. Please try again.";
}
}
} else{
echo "Error: " . $_FILES["photo"]["error"];
}
}?>