php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38235 mime_content_type does not return content type
Submitted: 2006-07-27 10:52 UTC Modified: 2007-07-17 10:08 UTC
Votes:21
Avg. Score:4.3 ± 0.9
Reproduced:19 of 19 (100.0%)
Same Version:5 (26.3%)
Same OS:15 (78.9%)
From: tony at marston-home dot demon dot co dot uk Assigned:
Status: Wont fix Package: Filesystem function related
PHP Version: 5CVS-2006-07-27 (CVS) OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tony at marston-home dot demon dot co dot uk
New email:
PHP Version: OS:

 

 [2006-07-27 10:52 UTC] tony at marston-home dot demon dot co dot uk
Description:
------------
When I use mime_content_type("picture.jpg") it always returns FALSE instead of "image/jpeg". At runtime I see the error "mime_content_type(): mime_magic not initialized".

I have the following in my php.ini file:

[mime_magic]
mime_magic.magicfile = "F:/PHP5/extras/magic.mime"
mime_magic.debug = On

This information shows up correctly with phpinfo().

I also notice in the phperror.log a lot of messages along the lines of:

[27-Jul-2006 11:37:13] PHP Warning:  PHP Startup: : (F:/PHP5/extras/magic.mime:274) 'L	application/x-bootable' is not a valid mimetype, entry skipped in Unknown on line 0

Reproduce code:
---------------
$content_type = mime_content_type("picture.jpg");
if (empty($content_type)) {
   echo "content_type is empty";
}

Expected result:
----------------
I expect it to return "image/jpeg" for this file.

Actual result:
--------------
It always returns FALSE.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-27 12:40 UTC] iliaa@php.net
it sounds to me like you mime magic file is invalid and 
subsequently results in an empty mime database in PHP. This 
would explain why the function always returns false. Where did 
you get the mime magic file that you are using?
 [2006-07-27 16:03 UTC] tony at marston-home dot demon dot co dot uk
It is the one included in the zip file which I downloaded from the PHP website.
 [2006-07-27 16:04 UTC] tony at marston-home dot demon dot co dot uk
I've also tried replacing it with the one I use on my other PC which runs PHP 4, but I get the same error.
 [2006-12-21 17:48 UTC] sonne at gaskanalen dot dk
When using a WinXp with 5.2 i get errors when loading the magic.mime file 

------ just a snippet
[21-Dec-2006 18:42:50] PHP Warning:  PHP Startup: : (C:\wamp\php\extras\magic.mime:360) 'HP48 text' is not a valid mimetype, entry skipped in Unknown on line 0
[21-Dec-2006 18:42:50] PHP Warning:  PHP Startup: : (C:\wamp\php\extras\magic.mime:361) 'hp200 (68010) BSD' is not a valid mimetype, entry skipped in Unknown on line 0
[21-Dec-2006 18:42:50] PHP Warning:  PHP Startup: : (C:\wamp\php\extras\magic.mime:362) 'hp300 (68020+68881) BSD' is not a valid mimetype, entry skipped in Unknown on line 0
[21-Dec-2006 18:42:50] PHP Warning:  PHP Startup: : (C:\wamp\php\extras\magic.mime:363) '370 XA sysV executable ' is not a valid mimetype, entry skipped in Unknown on line 0
[21-Dec-2006 18:42:50] PHP Warning:  PHP Startup: : (C:\wamp\php\extras\magic.mime:364) '370 XA sysV pure executable ' is not a valid mimetype, entry skipped in Unknown on line 0


I tryed downloading the zip file with windows binaries both from lates 5 and 4 series and use thoose magic.mime, they don't work

i also tryed jusing the magic file from apache, i don't get any errors in the log with this one, but the functions both mime_content_type and finfo_open dosn?t work with this either.
 [2007-07-17 10:08 UTC] jani@php.net
This extension was deprecated a while ago. Use the fileinfo extension instead: http://pecl.php.net/package/Fileinfo

(It will replace mime_magic in core in future anyway)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 28 19:01:28 2024 UTC