Skip to main content
added 120 characters in body
Source Link
palalvi
  • 395
  • 3
  • 3

Try theIn 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");
}

Try the below code -

$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");
}

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");
}
Source Link
palalvi
  • 395
  • 3
  • 3

Try the below code -

$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");
}