I am trying to upload files and check if the uploading files are really pdf files, so I resort to the fileinfo
functions in php.
The problem is that the code is not validating anything. It will allow all sorts of files to be uploaded including viruses. Currently, I am checking the file extension name but it's not secured and that's why am resorting to fileinfo
. Can someone tell me what is wrong with the code? I am running php version 5.3.5
if (function_exists('finfo_open')) {
$mime = finfo_open(FILEINFO_MIME_TYPE);
$mime_type = finfo_file($mime, $_FILES['myfile']['tmp_name']);
if ($mime_type == "application/pdf") {
echo "file is pdf";
} else {
echo "file is not pdf";
finfo_close($mime);
exit();
}
}