Aaron Crosman on 26 Jul 2006 16:21:23 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] PHP Mime detection


I'm working on a Debian 3.1 server, running Apache 2 and PHP 4.3.  The
mime_content_type function in PHP does not properly detect MP3 files.
Images see to come through fine, but it always defaults to text/plain
for MP3s.  Mod_mime_magic is running in Apache, and PHP is not giving
any errors that I can find.

I checked the /usr/share/misc/file/magic.mime and the MP3 definitions
look like everything I can find online:

# MPEG Layer 3 sound files
0       beshort&0xfffe  =0xfffa         audio/mpeg
#MP3 with ID3 tag
0       string          ID3             audio/mpeg

I noticed the problem when working with drupal, but I wrote a simple php
test page to see if mime_magic was working at all.  The relevant code
follows:

Image:  <?=mime_content_type('/path/to/image.jpg')?> <br />
MP3 File: <?=mime_content_type('/path/to/AudioFile.mp3')?> 

Results in:

Image: image/jpeg
MP3 File: text/plain

Anyone have thoughts of suggestions?

Aaron
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug