mime_content_type() 函数未定义
2022-08-30 19:12:36
我正在使用该功能进行文件上传,它在localhost上工作正常,但是我在实时服务器上遇到了以下错误:mime_content_type()
致命错误:调用未定义的函数 mime_content_type()
我正在使用该功能进行文件上传,它在localhost上工作正常,但是我在实时服务器上遇到了以下错误:mime_content_type()
致命错误:调用未定义的函数 mime_content_type()
更新:
mime_content_type()
不再被弃用,php7 现在支持这个函数。
我的答案的早期版本:
mime_content_type()
已被弃用,可能是因为 [fileinfo][1] 可以为您提供有关该文件的信息以及更多内容。您可以使用 finfo() 如下所示,
function _mime_content_type($filename) { $result = new finfo(); if (is_resource($result) === true) { return $result->file($filename, FILEINFO_MIME_TYPE); } return false; }