473,395 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Mime Magic and FileInfo Help

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
Jun 2 '08 #1
6 6476
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.
js*******@attglobal.net
==================

Jun 2 '08 #2
On Apr 15, 7:56 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
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"
Jun 2 '08 #3
tinman77 wrote:
On Apr 15, 7:56 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
>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.
js*******@attglobal.net
==================

Jun 2 '08 #4
On Apr 15, 8:27 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
tinman77 wrote:
On Apr 15, 7:56 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
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
Jun 2 '08 #5
tinman77 wrote:
On Apr 15, 8:27 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>tinman77 wrote:
>>On Apr 15, 7:56 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
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.
js*******@attglobal.net
==================

Jun 2 '08 #6
On Apr 15, 10:24 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
tinman77 wrote:
On Apr 15, 8:27 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
tinman77 wrote:
On Apr 15, 7:56 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
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.
Jun 2 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Phil Powell | last post by:
How do you detect an image MIME type if you know of the image in a directory? For example, I know of: if (is_file("$myImagePath/$myImageName")) { // FIND MIME TYPE BUT HOW I DUNNO } The...
1
by: ed_spain | last post by:
Hi Everyone, Before I write the script myself, I'm looking for PHP code that checks that a link's content type matches it's contents. I need this for my "broken link" checker script, which fails...
5
by: splodge | last post by:
This may seem like a stupid question but I want to check before I go ahead and build this... I am working on a portal, part of which allows users to upload files. Part of the array within...
3
by: Samuel | last post by:
Hi, How can I determine the type of a file from "magic bytes", similar to what the "file" command on unix does? I found http://docs.python.org/lib/module-mimetypes.html but this only seems...
0
by: comp.lang.php | last post by:
if (!function_exists('mime_content_type_fileinfo')) { /** * Will use {@link http://us2.php.net/fileinfo FileInfo} functions provided within {@link http://pecl.php.net PECL} bundle to return mime...
1
by: comp.lang.php | last post by:
<pre> if (!function_exists('mime_content_type_fileinfo')) { /** * Will use {@link http://us2.php.net/fileinfo FileInfo} functions provided within {@link http://pecl.php.net PECL} bundle to return...
5
by: Queez | last post by:
Afternoon, I've spent all morning trawling the net looking for an answer to this. In the end, I've had to resort to good old fashioned asking. How do you determine a file's MIME type using...
6
by: Mad Hatter | last post by:
Hi folks I'm a bit confused with an upload script that I've written. I want to be able to check the file type of an upload by checking the mime type but I'm not getting the results that I...
1
by: tinman77 | last post by:
Thanks in advance for everyone's help... My problem is that more often than I would like, I get attachments that for some reason or another do not include an extension. What I want to do is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.