Cannot access Fileinfo extension

Hey guys,

I have wamp setup locally on my dev machine. PHP version 5.3.0 is installed.

I was under the impression that Fileinfo is enabled by default as of version 5.3.0.

So, I tested to see if it’s working with the following line of code:


$finfo = finfo_open(FILEINFO_MIME_TYPE);

The browser output stated:

Fatal error: Call to undefined function finfo_open()”

So, then I had a look at my php.ini file and noticed the line corresponding to it was commented:

;extension=php_fileinfo.dll

So, I removed the semi-colon, restarted Apache, but still to no avail - I’m still getting told I’m trying to execute an undefined function.

Is there any other line that needs to be un-commented in the php.ini in order to get the function to run successfully?

Many thanks,

Bardi

Double check if the line is uncommented and also check the php_fileinfo.dll file is in the extension path. (something like php/ext/php_fileinfo.dll).

The line is definitely uncommented.

php_fileinfo.dll is located in ‘C:\wamp\bin\php\php5.3.0\ext’.

php.ini is located ‘C:\wamp\bin\php\php5.3.0\’.

The reference to php_fileinfo.dll in php.ini is:

extension=php_fileinfo.dll

I tried two different things to try get this to work:

  1. Copied php_fileinfo.dll to the php5.3.0 dir and

  2. Changed the line in php.ini to ‘extension=ext/php_fileinfo.dll’

Neither seemed to fix the problem, after restarting Apache on both occasions.

Any ideas?

:confused:

What does your phpinfo() say in there? Does it give library information in it? I did not use it in WAMP but in my individual installation (PHP, Apache, MySQL) it just works for me.

The only reference to ‘fileinfo’ in php.ini is ‘SplFileInfo’ in the list of Classes shown under the SPL heading. I’m not sure if that’s something else?

The SplFileInfo is unrelated, there should be a section entitled “fileinfo” if the extension was loaded properly. Are you sure you edited the correct php.ini file?

Yes there should be something like this if the extension is loaded successfully:
fileinfo


fileinfo support		enabled
version 			1.0.5-dev 

Apparently not! There was another php.ini file in c:\wamp\bin\apache\Apache2.2.11\bin. Uncommenting the fileinfo extension line in it has done the trick :slight_smile:

Thanks to both of you for your help.

It’s a common problem (having multiple php.inis floating around), glad you got it sorted. :slight_smile:

For anyone else stumbling on this thread, the phpinfo() output will detail the location of the php.ini file(s) being loaded.

Just for reference: you can click on the wampserver icon then go to PHP -> PHP extensions; here you can just click to enable and disable any extension, and it’ll restart Apache for you :slight_smile:

Thanks Jay for the tip - didn’t realise this.