Possible duplicate:
How to check file types of uploaded files in PHP?
I have a download function on my site and only PDF download is allowed. How to verify that the downloaded file is only pdf. Just as getimagesize() to write image files. Is there a way to check the file, which will be a PDF. my code is shown below.
$whitelist = array(".pdf"); foreach ($whitelist as $item) { if (preg_match("/$item\$/i", $_FILES['uploadfile']['name'])) { } else { redirect_to("index.php"); } } $uploaddir='uploads/'; $uploadfile = mysql_prep($uploaddir . basename($_FILES['uploadfile']['name'])); if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadfile)) { echo "succussfully uploaded"; }
in this redirect_to and mysql_prep is a function defined by me. But the mime type can be changed using headers.So is there a way to check the file, which will be orignal pdf?
html php pdf
StaticVariable
source share