mp3 MIMEType from FireFox 3 is application/download

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
skacc
Forum Newbie
Posts: 9
Joined: Sun Dec 21, 2008 8:08 am

mp3 MIMEType from FireFox 3 is application/download

Post by skacc »

Hello,
I am creating a function to validate filetypes when they are uploaded from a form, and i can not get around the folowing problem:
when i POST an .mp3 file using FF3.0.5 on Windows, then:
mime_content_type($_FILES['file']['tmp_name']) func returns: "audio/mpeg". That's ok.
But the $_FILES['file']['type'] contains "application/download".
IE works fine.

Is there anything i can do about that? Or what do you think if i let $_FILES['file']['type'] to be "application/download" when the file extension is mp3?

Oh, PHP Version 5.2.6

(Btw, i know instead of mime_content_type() i should use finfo_...(), but i can not get that func work on my local PC.)
cptnwinky
Forum Commoner
Posts: 84
Joined: Sat Dec 27, 2008 10:58 am
Location: Williamstown, MA

Re: mp3 MIMEType from FireFox 3 is application/download

Post by cptnwinky »

Well a hackish way to work around it would be too....

Code: Select all

 
if(preg_match("/^.*\.(mp3)$/i", $filename)) {
    // Overide the default value
    $_FILES['file']['type'] = "audio/mpeg";
}
 
skacc
Forum Newbie
Posts: 9
Joined: Sun Dec 21, 2008 8:08 am

Re: mp3 MIMEType from FireFox 3 is application/download

Post by skacc »

Ye, i think thats the best i can do.
Thank you for the idea
Post Reply