PHP’s Fileinfo extension under PHP 5.2 on Windows

I have been pulling my hair out this morning trying to get the PHP Fileinfo extension working under PHP 5.2.14 on Windows Server 2003 SE. Actually, to be accurate: I’ve been trying to get the PHP Fileinfo extension working; the pulling out of hair is a normal occurrence when doing anything on a Windows server, I am learning.

Last week I ended up installing PHP 5.2 rather than 5.3, all because I read that the LDAP extension wasn’t yet available for 5.3 on Windows. Then this week it looks like Fileinfo is available for 5.3 but not 5.2! Why oh why did I agree to move to a blasted Windows machine from my nice well-setup and working Ubuntu box?!

Anyway, I tried to install Fileinfo from PECL (with the same result with both the pecl and pear commands):

D:>pear install pecl/fileinfo
WARNING: "pear/Fileinfo" is deprecated in favor of "channel://php-src/ext/fileinfo/in php sources"
downloading Fileinfo-1.0.4.tgz ...
Starting to download Fileinfo-1.0.4.tgz (5,835 bytes)
.....done: 5,835 bytes
3 source files, building
ERROR: The DSP Fileinfo.dsp does not exist.

PECL bug #12603 is about this problem, but is still open and was no help.

The solution:

I’ll skip the details of the loops and deadends I traversed in trying to fix this. There were different PHP version, different DLLs, and any number of forums and Scroogle searches, but ultimately I:

  1. went down the list of old PHP releases to the most recent 5.2 release that had a separate Collection of PECL modules; this was 5.2.5, and I downloaded it;
  2. copied the php_fileinfo.dll from and put it where all the other extensions live;
  3. added the extension=php_fileinfo.dll line to php.ini; and
  4. restarted Apache.

So simple, and magically everything now works! So I thought I’d post this here, in case anyone else’s having the same problem. I’ll add a note to that bug report too.

7 thoughts on “PHP’s Fileinfo extension under PHP 5.2 on Windows”

  1. Sam, I’m trying to get the php_fileinfo.dll set up using windows 7, IIS 7.5, PHP 5.2.17.
    have you had any luck, or comments from folks with this issue using IIS?

    I’ve followed your advice above and have had no luck getting the file to actually load.

    I get a 500 error with this in the log:
    PHP Warning: PHP Startup: Unable to load dynamic library ‘C:\Program Files (x86)\PHP\v5.2\ext\php_fileinfo.dll’ – The specified module could not be found.
    in Unknown on line 0

    push me in a new direction. please.

  2. @John: I assume the file is actually at C:\Program Files (x86)\PHP\v5.2\ext\php_fileinfo.dll? If it is, I’ve no idea why PHP can’t find it, sorry! Perhaps some permissions problem on that particular file? I gave up trying to use IIS ages ago; it’s too confusing, and I’d rather keep my Apache skills—they’re useful in more places… :-)

Leave a Reply

Your email address will not be published. Required fields are marked *