finfo_open on PHP 5.3.3

Hi,

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";
    exit();
}
  $fmime = finfo_file($finfo, $file);
  finfo_close($finfo);

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+?

Cheers,
Rhys

EDIT: Figured it out. The extension needed activating.

Cheers

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.