tags:

views:

52

answers:

2

i am using PHP 5.3 and i have checked that my fileinfo is enabled. But when i run my code its occurring an error

Fatal error: Call to undefined function finfo_open()

Anyone can help me to fixed this, here is my code.

$mime=finfo_open(FILEINFO_MIME,filename);
     echo "File Type is: ".$mime;
A: 

The "filename" needs to be a file that contains a "MIME magic" database. If you want to determine the type of file, you first need to open the MIME database, then ask that database to identify the file.

For instance, if the MIME database is stored in /usr/share/misc/magic.mgc (most Linux distributions store it there), you can do:

// open MIME database
$finfo = finfo_open(FILEINFO_MIME, "/usr/share/misc/magic.mgc");
if (!$finfo)
    die("error opening MIME info database");

// print out MIME information of "some-file-name-here"
echo finfo_file($finfo, "some-file-name-here");

finfo_close($finfo);

However, if this is a virtual hosting provider, you might need to copy the magic.mgc file into your public web directory.

intgr
Sorry, this answer is irrelevant now because the asker updated his question.
intgr
A: 

Perhaps you are missing some configuration in php.ini. Either you don't have extentions (or dynamic libraries) turned on or as suggestet here a line in php.ini.

Checklist:

  • Is there a line in your php.ini enable_dl = On?

  • Do you have a line extension=fileinfo.so?

stefita
I checked my php.ini file and enable_dl = On i found this and extension=php_fileinfo.dll instead of extension=fileinfo.so
Talha Bin Shakir
you are working on windows then... Did you restart your apache server after installing the extention?
stefita