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));
What version of PHP do you have? PHP 5.3.0 and later have Fileinfo built in, but on Windows you must enable it manually in your
php.ini
. You can find further information in the documentation.If you using XAMPP, you enable
extension=php_fileinfo.dll
in php.iniIf you are using WAMP then Go to PHP extensions and enbale PHP_fileinfo and restart all serverices.
I had this same issue with PHP.I did the following steps:
Then save and restart your web server.
Have a look at your php.ini file and check that the
fileinfo.so
orphp_fileinfo.dll
is activated (depending on your platform and version).There should be a line similar to
in your php.ini file
For those have had it working fine, but then this error appears:
Some hosting providers (e.g., Dreamhost) allow customers to override default PHP settings in a configuration file, often with a path something like:
~/.php/5.4/phprc
That version number in the path can be a problem if you upgrade PHP (or it is upgraded on your behalf). Any custom settings from the prior version, including one enabling the fileinfo extension, will be missing in the newer version. Usually you can just copy the config file to the appropriate new config directory and restart the server.