finfo_open on PHP 5.3.3


I have the following code to get a MIME type:

$file = OFF_URL . "file/".$filename;
  $finfo = finfo_open(FILEINFO_MIME_TYPE);
  if (!$finfo) {
    echo "Opening fileinfo database failed";
  $fmime = finfo_file($finfo, $file);

But I get the following error:
PHP Fatal error: Call to undefined function finfo_open() in …

It’s the first time I’ve used finfo, but I thought it was included with PHP 5.3.0+?


EDIT: Figured it out. The extension needed activating.


finfo is not a PHP extension. It is a PEAR Module you will need to install PEAR first and then install the finfo PEAR module by running this command
pear install fileinfo
you also might have to go edit php.ini to include the extension

Thanks. I was having some trouble. It’s a windows server and PEAR is installed. editting php.ini seems to have worked so it must have been installed. Cheers.