这在PHP 5中有效,但是现在不行了:if (function_exists('finfo_open')) { $mime = finfo_open(FILEINFO_MIME_TYPE); $mime_type = finfo_file($mime, "FILE-PATH"); if($mime_type == array("application/pdf", "image/jpeg", "image/png")) echo "file is pdf"; else echo "file is not pdf"; finfo_close($mime);}
1 回答
慕无忌1623718
TA贡献1744条经验 获得超4个赞
您将字符串与数组进行了比较,这是正确的代码:
if (function_exists('finfo_open')) {
$mime = finfo_open(FILEINFO_MIME_TYPE);
if (in_array(finfo_file($mime, 'FILE-PATH'), array('application/pdf', 'image/jpeg', 'image/png')))
echo 'file is pdf';
else
echo 'file is not pdf';
finfo_close($mime);
}
- 1 回答
- 0 关注
- 183 浏览
添加回答
举报
0/150
提交
取消