php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26918 mime_content_type() returns text/plain always if mime_magic.debug is not set
Submitted: 2004-01-15 06:37 UTC Modified: 2004-01-16 06:06 UTC
From: jalonso at art3mis dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.0.0b3 (beta3) OS: debian / linux
Private report: No CVE-ID: None
 [2004-01-15 06:37 UTC] jalonso at art3mis dot com
Description:
------------
mime_content_type() will return text/plain for all files except if you set mime_magic.debug to On on php.ini. It won't work if you try to change it with ini_alter('mime_magic.debug').

Reproduce code:
---------------
php.ini has 
mime_magic.magicfile = "/usr/share/misc/file/magic.mime"
;mime_magic.debug     = On


<?php
echo mime_content_type('/bin/ping');
?>

Expected result:
----------------
application/x-executable

Actual result:
--------------
text/plain

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-16 06:06 UTC] sniper@php.net
You can't set these options in scripts. Only in php.ini.
And you can only use the magic file that comes with Apache..

From manual (http://www.php.net/manual/en/ref.mime-magic.php):

"Note:  This extension is not capable of handling the fully decorated magic file that generally comes with standard Linux distro's and is supposed to be used with recent versions of file command."

The mime_magic.debug option, when set to On, only outputs errors during startup. So you need to set 'display_startup_errors = On' too in php.ini if you turn it on. Just DO NOT use this option, it's meant for DEBUGGING.

See also phpinfo() output for this extension..it will say 
"mime_magic support => invalid magic file, disabled" when you're trying to use invalid file with it.



 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 08:01:32 2024 UTC