PHP fileinfo is undefined function

2019-01-02 21:15发布

Whenever I try to get the mime content type from php, it echos:

Fatal error: Class 'finfo' not found in /home/jobynadel/finadel.com/video/finfo.php on line 4

or

Fatal error: Call to undefined function finfo_open in /home/jobynadel/finadel.com/video/finfo.php on line 4

I just can't figure it out!

The code I am using is:

$file_info = new finfo(FILEINFO_MIME_TYPE);
// See constant value http://php.net/manual/en/fileinfo.constants.php#113687 
$mime_type = $file_info->buffer(file_get_contents($file));

7条回答
不流泪的眼
2楼-- · 2019-01-02 21:41

Windows users: just edit php.ini and uncomment this line:

extension=php_fileinfo.dll

I.e. remove the preceding semicolon from

;extension=php_fileinfo.dll

Remember to restart Apache for new php.ini to take effect.

查看更多
登录 后发表回答