mime_content_type()函数不起作用 [英] mime_content_type() function not working
问题描述
我正在使用mime_content_type()函数进行文件上传,本地主机可以正常工作,但在线文件中显示一些错误
i am using mime_content_type() function for file upload, localhost it work correctly but it show some error in online file
致命错误:调用未定义的函数mime_content_type()
Fatal error: Call to undefined function mime_content_type()
推荐答案
更新:
mime_content_type()
不再被弃用,php7现在支持此功能.
mime_content_type()
is no longer deprecated, php7 has support for this function now.
我的答案的早期版本:
mime_content_type()
已过时,可能是因为[fileinfo] [1] 可以为您提供有关文件的信息以及更多信息.
mime_content_type()
is deprecated, probably because [fileinfo][1] can give you those information about the file and more.
您可以使用如下所示的finfo(),
You can use finfo() like shown below,
function _mime_content_type($filename) {
$result = new finfo();
if (is_resource($result) === true) {
return $result->file($filename, FILEINFO_MIME_TYPE);
}
return false;
}
引用: https://stackoverflow.com/a/1263977/1161412
[1]: http://php.net/manual/zh/class. finfo.php
这篇关于mime_content_type()函数不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!