PHP文件上传finfo MIME类型无法正确检测?

时间:2014-08-04 02:08:14

标签: php file-upload mime-types

我正在检查上传文件的MIME类型并强制扩展,如下所示:

$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $_FILES['attachment']['tmp_name']);

if ($mime == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') {
    $extension = ".docx";
} else if ($mime == 'application/msword') {
    $extension = ".doc";
}

无论我上传的文件是.docx还是.doc,语句总是评估为.doc。为什么没有检测到docx?我使用的是错误的mime类型吗?

excel文件也是如此(xlsx,xls)..

0 个答案:

没有答案
相关问题