|  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
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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
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
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.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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-27 12:40 UTC]
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

 [2007-07-17 10:08 UTC]
This extension was deprecated a while ago. Use the fileinfo extension instead:

(It will replace mime_magic in core in future anyway)
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Tue Jun 19 01:01:42 2018 UTC