How To Enable the PHP Fileinfo Extension under Windows

These five steps will hopefully help you to enable the Fileinfo extension for PHP under Windows. These steps assume you have the extension installed (e.g. php\ext\php_fileinfo.dll). They worked for me using Xampplite 1.7.1 and PHP 5.2.9.

  1. Download GnuWin version 4.23 (the version number is significant) - your best bet is http://sourceforge.net/projects/gnuwin32/files/file/4.23/file-4.23-bin.zip/download
  2. Extract the contents of file-4.23-bin.zip\share\file\ to a folder on your machine - I went with path\to\xampplite\php\extras\magic\
  3. Add an environment variable, named MAGIC, to your machine with the value pointing at the file named magic - in my example: path\to\xampplite\php\extras\magic\magic\
  4. Add a line (or uncomment an existing line) to your php.ini: extension=php_fileinfo.dll
  5. Restart Apache if it was already running.

That's it!

These steps are probably what you need if you are seeing errors such as these:

  • Failed to load magic database
  • Fileinfo could not load the magic file
  • The given magicfile can not be read
  • The given magicfile is not accepted by finfo

(The last two of these error messages are specific to Zend Framework)

References:
* http://php.net/manual/en/function.finfo-open.php#82551
* http://pecl.php.net/bugs/bug.php?id=7555

Leave a comment

Recent Entries

  • Is The Internet On?

    The Internet is critical in its role in sustaining life here on Earth and it is vital to know whether or not the Internet is On. ...

  • The TCP/IP Guide - Greasemonkey Userscript

    jah has written a greasemonkey userscript to fix the page layout for The TCP/IP Guide free online edition - it's very simple, but it took him ages!...

  • PicaVue

    jah has begun work on an open source javascript gallery to display his Picasa Web Albums - it's called PicaVue...

  • Nmap 5 - An Introduction

    The newest version of Nmap - Nmap 5.00 - is now available for download and is the best Nmap ever. This is a short introduction to Nmap and the Nmap family of tools: Zenmap; Ncat and Ndiff which are included with this latest release....

  • Enable apache mod_userdir on Debian

    How to enable mod_userdir for apache2 on Debian 5.0 (Lenny)....