Hi all,
I am trying to check for mime types. The following extensions can be uploaded .txt, .doc and .pdf
To check for extensions I use
Now for MIME type check I useCode:$name = $_FILES['userfile']['name']; $extArray = array('.doc', '.txt', '.pdf'); $ext = strtolower(substr($name, -4)); echo $ext; if (!in_array($ext, $extArray)) { return false; echo "Geen text"; } else { echo "File is ".$ext; }
Is application/pdf correct for .pdf? and will plain/text be correct for .doc??Code:$mimeArray = array('text/plain', 'application/pdf'); $mime = mime_content_type($_FILES['userfile']['tmp_name']); if (!in_array($mime, $mimeArray)) { return false; } else { echo "Mime type is ".$mime;//test }
tx







Bookmarks