我有這個片段Mime類型PDF PHP上傳
if ($_FILES['tax']['error'] !== UPLOAD_ERR_OK) {
die("Upload failed with error " . $_FILES['tax']['error']);
}
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES['tax']['tmp_name']);
$ok = false;
switch ($mime) {
case 'image/gif':
case 'application/pdf':
case 'image/png':
$ok = true;
default:
die("Unknown/not permitted file type");
}
move_uploaded_file($_FILES["tax"]["tmp_name"],"pints/" . $_FILES["tax"]["name"]);
當我嘗試上傳的圖片人稱它是不允許的文件類型,當文件是PDF文檔,是application/pdf
正確MIME類型?
[適用於PDF文件的MIME類型]可能的副本(http://stackoverflow.com/questions/312230/proper-mime-type-for-pdf-files) –
$ mime = $ _FILES [「file」] [「type」] – zszen