I am trying to use finfo to determine if the file is an image file before uploading it into the server. My question though is that the code below is only for jpeg, but I have other file types as well to allow. So I have 2 questions:
Question 1:
How can I use finfo to check for multiple file types such as gif, tiff, png, ico etc.
Question 2: Do I need to use other validation methods to check to see if the is an image or is I what I got below be enough?
Below is code:
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimetype = image_type_to_mime_type(exif_imagetype('/path/to/file.jpg'));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/tiff")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/bmp")
|| ($_FILES["file"]["type"] == "image/ico")
{
if ($finfo !== FALSE){
move_uploaded_file($_FILES["fileImage"]["tmp_name"],
"ImageFiles/" . $_FILES["fileImage"]["name"]);
$result = 1;
@finfo_close($finfo);
}
}