Skip to main content
2 of 2
added 120 characters in body
palalvi
  • 395
  • 3
  • 3

In below code we find out mime type of uploaded file. Then using switch case we check mime type of uploaded file is application/pdf or not.

$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES['file']['tmp_name']);
$ok = false;
switch ($mime) {
   case 'application/pdf';
        $ok = true;
   default:
       die("Unknown/not permitted file type");
}
palalvi
  • 395
  • 3
  • 3