<!-- your file fields are-->
<input type="file" name="photoname[]" id="file1"/>
<input type="file" name="photoname[]" id="file2"/>
<input type="file" name="photoname[]" id="file3"/>
<input type="file" name="photoname[]" id="file4"/>
<?php
//php code to validate
$allowedExtensions = array("jpg","jpeg","pjpeg");
$error_msg = array();
foreach ($_FILES['photoname'] as $file) {
$file_name = $file['name'];
$file_ext = substr($file_name, strrpos($file_name, '.')+1);
if(!in_array($file_ext,$allowedExtensions)){
$error_msg[] = 'File '.$file_name.' is not allowed';
}
}
if(count($error_msg)>0){
foreach($error_msg as $errors){
echo $errors."<br/>";
}
}
?>
Bookmarks