473,581 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.dl l and also added the lines
mime_magic.debu g = Off and
mime_magic.magi cfile = "C:\Program Files\PHP\extra s\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\wwwr oot\visl\contri bute.php on
line 43

Warning: finfo::buffer() [function.finfo-buffer]: The invalid fileinfo
object. in C:\Inetpub\wwwr oot\visl\contri bute.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 6491
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.dl l and also added the lines
mime_magic.debu g = Off and
mime_magic.magi cfile = "C:\Program Files\PHP\extra s\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\wwwr oot\visl\contri bute.php on
line 43

Warning: finfo::buffer() [function.finfo-buffer]: The invalid fileinfo
object. in C:\Inetpub\wwwr oot\visl\contri bute.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.magi cfile in your php.ini file?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Jun 2 '08 #2
On Apr 15, 7:56 am, Jerry Stuckle <jstuck...@attg lobal.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.dl l and also added the lines
mime_magic.debu g = Off and
mime_magic.magi cfile = "C:\Program Files\PHP\extra s\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\wwwr oot\visl\contri bute.php on
line 43
Warning: finfo::buffer() [function.finfo-buffer]: The invalid fileinfo
object. in C:\Inetpub\wwwr oot\visl\contri bute.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.magi cfile in your php.ini file?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===
mime_magic.magi cfile = "C:\Program Files\PHP\extra s\magic.mime"
Jun 2 '08 #3
tinman77 wrote:
On Apr 15, 7:56 am, Jerry Stuckle <jstuck...@attg lobal.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_magi c.dll and php_fileinfo.dl l and also added the lines
mime_magic.de bug = Off and
mime_magic.ma gicfile = "C:\Program Files\PHP\extra s\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\wwwr oot\visl\contri bute.php on
line 43
Warning: finfo::buffer() [function.finfo-buffer]: The invalid fileinfo
object. in C:\Inetpub\wwwr oot\visl\contri bute.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.magi cfile in your php.ini file?

--
============== ====
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attg lobal.net
============== ====

mime_magic.magi cfile = "C:\Program Files\PHP\extra s\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*******@attgl obal.net
=============== ===

Jun 2 '08 #4
On Apr 15, 8:27 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
tinman77 wrote:
On Apr 15, 7:56 am, Jerry Stuckle <jstuck...@attg lobal.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.dl l and also added the lines
mime_magic.deb ug = Off and
mime_magic.mag icfile = "C:\Program Files\PHP\extra s\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\wwwr oot\visl\contri bute.php on
line 43
Warning: finfo::buffer() [function.finfo-buffer]: The invalid fileinfo
object. in C:\Inetpub\wwwr oot\visl\contri bute.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.magi cfile in your php.ini file?
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===
mime_magic.magi cfile = "C:\Program Files\PHP\extra s\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...@attgl obal.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...@attg lobal.netwrote:
>tinman77 wrote:
>>On Apr 15, 7:56 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
tinman77 wrote:
Hello,
I'm having a terrible time using the functions finfo_open and
finfo_fil e. I'm using PHP 5 on IIS 5.1 and Windows XP. I have enabled
php_mime_ma gic.dll and php_fileinfo.dl l and also added the lines
mime_magic. debug = Off and
mime_magic. magicfile = "C:\Program Files\PHP\extra s\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\wwwr oot\visl\contri bute.php on
line 43
Warning: finfo::buffer() [function.finfo-buffer]: The invalid fileinfo
object. in C:\Inetpub\wwwr oot\visl\contri bute.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.magi cfile in your php.ini file?
--
============ ======
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@at tglobal.net
============ ======
mime_magic.magi cfile = "C:\Program Files\PHP\extra s\magic.mime"
Don't give it the extension just "...\magic" . The extension is added
automaticall y.

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...@attg lobal.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*******@attgl obal.net
=============== ===

Jun 2 '08 #6
On Apr 15, 10:24 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
tinman77 wrote:
On Apr 15, 8:27 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
tinman77 wrote:
On Apr 15, 7:56 am, Jerry Stuckle <jstuck...@attg lobal.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_mag ic.dll and php_fileinfo.dl l and also added the lines
mime_magic.d ebug = Off and
mime_magic.m agicfile = "C:\Program Files\PHP\extra s\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\wwwr oot\visl\contri bute.php on
line 43
Warning: finfo::buffer() [function.finfo-buffer]: The invalid fileinfo
object. in C:\Inetpub\wwwr oot\visl\contri bute.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.magi cfile in your php.ini file?
--
============= =====
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@att global.net
============= =====
mime_magic.magi cfile = "C:\Program Files\PHP\extra s\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...@attgl obal.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...@attgl obal.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=1887 8) 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(FILE INFO_MIME,'C:\P HP\extras\magic ');
$mimetype = finfo_file($han dle,$_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
9091
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 only way I could think of was to determine the extension of the
1
2780
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 to spot the "broken" links http://www.awin1.com/show.php?mid=1014&linkid=36515&aid=49007 and...
5
2997
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 $_FILES superglobal gives the mime type for the file. Is this 100% reliable / accurate? If the mime type says the file type is jpeg is it always right?...
3
3551
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 to use the filename (extension) for finding the type. Any hints?
0
1778
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 type * * @param string $file * @return string $mime_type * @see mime_content_type */
1
3528
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 mime type * * @param string $file * @return string $mime_type * @see mime_content_type
5
20996
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 VB.NET? The problem is: - I have an ASP.NET web application - I can display a list of all files in a directory on the server (it's a "directory...
6
6241
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 thought I should. According to what I've read .zip files should return something like 'application/zip' or 'application/x-zip-compressed', RAR should...
1
6719
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 create a C# app that based on a file on my hard drive that I specify, will spit back to me the mime type. I can do the rest from there. I have...
0
7862
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7789
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8144
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8301
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6551
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3803
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3820
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.