Mime Magic and FileInfo Help

Mime Magic and FileInfo Help

am 15.04.2008 02:43:53 von rodey

Hello,

I'm having a terrible time using the functions finfo_open and
finfo_file. I'm using PHP 5 on IIS 5.1 and Windows XP. I have enabled
php_mime_magic.dll and php_fileinfo.dll and also added the lines
mime_magic.debug = Off and
mime_magic.magicfile = "C:\Program Files\PHP\extras\magic.mime".

Now my phpinfo() says fileinfo support is enabled and mime_magic
support is enabled. However, I keep getting this error:
Warning: finfo::finfo() [function.finfo-finfo]: Failed to load magic
database at '(null)'. in C:\Inetpub\wwwroot\visl\contribute.php on
line 43

Warning: finfo::buffer() [function.finfo-buffer]: The invalid fileinfo
object. in C:\Inetpub\wwwroot\visl\contribute.php on line 44

I have tried everything I can think of and I have Googled everything
under the sun I can think of. Can anyone help?

Thanks!

Ryan

Re: Mime Magic and FileInfo Help

am 15.04.2008 13:56:39 von Jerry Stuckle

tinman77 wrote:
> Hello,
>
> I'm having a terrible time using the functions finfo_open and
> finfo_file. I'm using PHP 5 on IIS 5.1 and Windows XP. I have enabled
> php_mime_magic.dll and php_fileinfo.dll and also added the lines
> mime_magic.debug = Off and
> mime_magic.magicfile = "C:\Program Files\PHP\extras\magic.mime".
>
> Now my phpinfo() says fileinfo support is enabled and mime_magic
> support is enabled. However, I keep getting this error:
> Warning: finfo::finfo() [function.finfo-finfo]: Failed to load magic
> database at '(null)'. in C:\Inetpub\wwwroot\visl\contribute.php on
> line 43
>
> Warning: finfo::buffer() [function.finfo-buffer]: The invalid fileinfo
> object. in C:\Inetpub\wwwroot\visl\contribute.php on line 44
>
> I have tried everything I can think of and I have Googled everything
> under the sun I can think of. Can anyone help?
>
> Thanks!
>
> Ryan
>

What do you have for mime_magic.magicfile in your php.ini file?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Mime Magic and FileInfo Help

am 16.04.2008 01:05:25 von rodey

On Apr 15, 7:56 am, Jerry Stuckle wrote:
> tinman77 wrote:
> > Hello,
>
> > I'm having a terrible time using the functions finfo_open and
> > finfo_file. I'm using PHP 5 on IIS 5.1 and Windows XP. I have enabled
> > php_mime_magic.dll and php_fileinfo.dll and also added the lines
> > mime_magic.debug = Off and
> > mime_magic.magicfile = "C:\Program Files\PHP\extras\magic.mime".
>
> > Now my phpinfo() says fileinfo support is enabled and mime_magic
> > support is enabled. However, I keep getting this error:
> > Warning: finfo::finfo() [function.finfo-finfo]: Failed to load magic
> > database at '(null)'. in C:\Inetpub\wwwroot\visl\contribute.php on
> > line 43
>
> > Warning: finfo::buffer() [function.finfo-buffer]: The invalid fileinfo
> > object. in C:\Inetpub\wwwroot\visl\contribute.php on line 44
>
> > I have tried everything I can think of and I have Googled everything
> > under the sun I can think of. Can anyone help?
>
> > Thanks!
>
> > Ryan
>
> What do you have for mime_magic.magicfile in your php.ini file?
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

mime_magic.magicfile = "C:\Program Files\PHP\extras\magic.mime"

Re: Mime Magic and FileInfo Help

am 16.04.2008 02:27:44 von Jerry Stuckle

tinman77 wrote:
> On Apr 15, 7:56 am, Jerry Stuckle wrote:
>> tinman77 wrote:
>>> Hello,
>>> I'm having a terrible time using the functions finfo_open and
>>> finfo_file. I'm using PHP 5 on IIS 5.1 and Windows XP. I have enabled
>>> php_mime_magic.dll and php_fileinfo.dll and also added the lines
>>> mime_magic.debug = Off and
>>> mime_magic.magicfile = "C:\Program Files\PHP\extras\magic.mime".
>>> Now my phpinfo() says fileinfo support is enabled and mime_magic
>>> support is enabled. However, I keep getting this error:
>>> Warning: finfo::finfo() [function.finfo-finfo]: Failed to load magic
>>> database at '(null)'. in C:\Inetpub\wwwroot\visl\contribute.php on
>>> line 43
>>> Warning: finfo::buffer() [function.finfo-buffer]: The invalid fileinfo
>>> object. in C:\Inetpub\wwwroot\visl\contribute.php on line 44
>>> I have tried everything I can think of and I have Googled everything
>>> under the sun I can think of. Can anyone help?
>>> Thanks!
>>> Ryan
>> What do you have for mime_magic.magicfile in your php.ini file?
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
> mime_magic.magicfile = "C:\Program Files\PHP\extras\magic.mime"
>

Don't give it the extension just "...\magic". The extension is added
automatically.

BTW - did you try googling for this? A search on just "mime.magic"
turned up a bogus bug report containing this information as the fifth hit.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Mime Magic and FileInfo Help

am 16.04.2008 03:35:04 von rodey

On Apr 15, 8:27 pm, Jerry Stuckle wrote:
> tinman77 wrote:
> > On Apr 15, 7:56 am, Jerry Stuckle wrote:
> >> tinman77 wrote:
> >>> Hello,
> >>> I'm having a terrible time using the functions finfo_open and
> >>> finfo_file. I'm using PHP 5 on IIS 5.1 and Windows XP. I have enabled
> >>> php_mime_magic.dll and php_fileinfo.dll and also added the lines
> >>> mime_magic.debug = Off and
> >>> mime_magic.magicfile = "C:\Program Files\PHP\extras\magic.mime".
> >>> Now my phpinfo() says fileinfo support is enabled and mime_magic
> >>> support is enabled. However, I keep getting this error:
> >>> Warning: finfo::finfo() [function.finfo-finfo]: Failed to load magic
> >>> database at '(null)'. in C:\Inetpub\wwwroot\visl\contribute.php on
> >>> line 43
> >>> Warning: finfo::buffer() [function.finfo-buffer]: The invalid fileinfo
> >>> object. in C:\Inetpub\wwwroot\visl\contribute.php on line 44
> >>> I have tried everything I can think of and I have Googled everything
> >>> under the sun I can think of. Can anyone help?
> >>> Thanks!
> >>> Ryan
> >> What do you have for mime_magic.magicfile in your php.ini file?
>
> >> --
> >> ==================
> >> Remove the "x" from my email address
> >> Jerry Stuckle
> >> JDS Computer Training Corp.
> >> jstuck...@attglobal.net
> >> ==================
>
> > mime_magic.magicfile = "C:\Program Files\PHP\extras\magic.mime"
>
> Don't give it the extension just "...\magic". The extension is added
> automatically.
>
> BTW - did you try googling for this? A search on just "mime.magic"
> turned up a bogus bug report containing this information as the fifth hit.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

Jerry,

I took your advice and removed the ".mime" and now I get "mime_magic
support invalid magic file, disabled" in phpinfo(). I Googled
everything I could think of yesterday and that's why I posted here.
And I'm still getting the same errors about failing to load the magic
database at '(null)'.

Ryan

Re: Mime Magic and FileInfo Help

am 16.04.2008 04:24:06 von Jerry Stuckle

tinman77 wrote:
> On Apr 15, 8:27 pm, Jerry Stuckle wrote:
>> tinman77 wrote:
>>> On Apr 15, 7:56 am, Jerry Stuckle wrote:
>>>> tinman77 wrote:
>>>>> Hello,
>>>>> I'm having a terrible time using the functions finfo_open and
>>>>> finfo_file. I'm using PHP 5 on IIS 5.1 and Windows XP. I have enabled
>>>>> php_mime_magic.dll and php_fileinfo.dll and also added the lines
>>>>> mime_magic.debug = Off and
>>>>> mime_magic.magicfile = "C:\Program Files\PHP\extras\magic.mime".
>>>>> Now my phpinfo() says fileinfo support is enabled and mime_magic
>>>>> support is enabled. However, I keep getting this error:
>>>>> Warning: finfo::finfo() [function.finfo-finfo]: Failed to load magic
>>>>> database at '(null)'. in C:\Inetpub\wwwroot\visl\contribute.php on
>>>>> line 43
>>>>> Warning: finfo::buffer() [function.finfo-buffer]: The invalid fileinfo
>>>>> object. in C:\Inetpub\wwwroot\visl\contribute.php on line 44
>>>>> I have tried everything I can think of and I have Googled everything
>>>>> under the sun I can think of. Can anyone help?
>>>>> Thanks!
>>>>> Ryan
>>>> What do you have for mime_magic.magicfile in your php.ini file?
>>>> --
>>>> ==================
>>>> Remove the "x" from my email address
>>>> Jerry Stuckle
>>>> JDS Computer Training Corp.
>>>> jstuck...@attglobal.net
>>>> ==================
>>> mime_magic.magicfile = "C:\Program Files\PHP\extras\magic.mime"
>> Don't give it the extension just "...\magic". The extension is added
>> automatically.
>>
>> BTW - did you try googling for this? A search on just "mime.magic"
>> turned up a bogus bug report containing this information as the fifth hit.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
> Jerry,
>
> I took your advice and removed the ".mime" and now I get "mime_magic
> support invalid magic file, disabled" in phpinfo(). I Googled
> everything I could think of yesterday and that's why I posted here.
> And I'm still getting the same errors about failing to load the magic
> database at '(null)'.
>
> Ryan
>

Ryan,

It sounds like it's now finding the file, but the file is in the
incorrect format.

Not sure if it makes a difference, but the default file has UNIX line
endings; you didn't possibly try to edit and save it with a Windows
editor, did you?

How does the file look?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Mime Magic and FileInfo Help

am 19.04.2008 21:45:30 von rodey

On Apr 15, 10:24 pm, Jerry Stuckle wrote:
> tinman77 wrote:
> > On Apr 15, 8:27 pm, Jerry Stuckle wrote:
> >> tinman77 wrote:
> >>> On Apr 15, 7:56 am, Jerry Stuckle wrote:
> >>>> tinman77 wrote:
> >>>>> Hello,
> >>>>> I'm having a terrible time using the functions finfo_open and
> >>>>> finfo_file. I'm using PHP 5 on IIS 5.1 and Windows XP. I have enabled
> >>>>> php_mime_magic.dll and php_fileinfo.dll and also added the lines
> >>>>> mime_magic.debug = Off and
> >>>>> mime_magic.magicfile = "C:\Program Files\PHP\extras\magic.mime".
> >>>>> Now my phpinfo() says fileinfo support is enabled and mime_magic
> >>>>> support is enabled. However, I keep getting this error:
> >>>>> Warning: finfo::finfo() [function.finfo-finfo]: Failed to load magic
> >>>>> database at '(null)'. in C:\Inetpub\wwwroot\visl\contribute.php on
> >>>>> line 43
> >>>>> Warning: finfo::buffer() [function.finfo-buffer]: The invalid fileinfo
> >>>>> object. in C:\Inetpub\wwwroot\visl\contribute.php on line 44
> >>>>> I have tried everything I can think of and I have Googled everything
> >>>>> under the sun I can think of. Can anyone help?
> >>>>> Thanks!
> >>>>> Ryan
> >>>> What do you have for mime_magic.magicfile in your php.ini file?
> >>>> --
> >>>> ==================
> >>>> Remove the "x" from my email address
> >>>> Jerry Stuckle
> >>>> JDS Computer Training Corp.
> >>>> jstuck...@attglobal.net
> >>>> ==================
> >>> mime_magic.magicfile = "C:\Program Files\PHP\extras\magic.mime"
> >> Don't give it the extension just "...\magic". The extension is added
> >> automatically.
>
> >> BTW - did you try googling for this? A search on just "mime.magic"
> >> turned up a bogus bug report containing this information as the fifth hit.
>
> >> --
> >> ==================
> >> Remove the "x" from my email address
> >> Jerry Stuckle
> >> JDS Computer Training Corp.
> >> jstuck...@attglobal.net
> >> ==================
>
> > Jerry,
>
> > I took your advice and removed the ".mime" and now I get "mime_magic
> > support invalid magic file, disabled" in phpinfo(). I Googled
> > everything I could think of yesterday and that's why I posted here.
> > And I'm still getting the same errors about failing to load the magic
> > database at '(null)'.
>
> > Ryan
>
> Ryan,
>
> It sounds like it's now finding the file, but the file is in the
> incorrect format.
>
> Not sure if it makes a difference, but the default file has UNIX line
> endings; you didn't possibly try to edit and save it with a Windows
> editor, did you?
>
> How does the file look?
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

RESOLVED:
I have spent countless hours trying to figure this one out and I have
but I've done it a bit different than how I was trying. I downloaded
GnuWin32 (http://sourceforge.net/project/showfiles.php?
group_id=23617&package_id=18878) and installed it. In the directory C:
\Program Files\GnuWin32\share\file there are 4 files. Place these
files in C:\PHP\extras (or whatever your setup is) and then pass the
directory to finfo_open as the 2nd parameter. Note in my example below
magic is a file without an extension (ie. not a directory). Hope this
helps someone.

Example:
$handle = finfo_open(FILEINFO_MIME,'C:\PHP\extras\magic');
$mimetype = finfo_file($handle,$_FILES['media']['tmp_name']);

I found my solution at http://pecl.php.net/bugs/bug.php?id=7555.