Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP mime type standardization

Tags:

mime-types

php

So as I am creating a site that deals with uploads of a variety of kinds, I am coming across mime types that don't exist on every OS/browser and that are unexpected. Examples are the image/pjepg(Windows) and recently mp3 come in as audio/mp3(chrome) and not audio/mpeg.

So I was wondering is there a standardization of mime types for PHP? Or is it based on operating system and browsers?

like image 721
Devin Dixon Avatar asked Oct 12 '22 15:10

Devin Dixon


2 Answers

There is a standard for these types, however they are not always effectively enforced by browsers. For example Internet Explorer does not support the 'application/javascript' type, you have to use 'text/javascript' even though this is deprecated.

Please see the following link for the types and their corresponding documentation:

http://www.iana.org/assignments/media-types/index.html

like image 170
Tim Avatar answered Nov 11 '22 01:11

Tim


You should never trust the uploader-supplied MIME type information anyway, since it's easily faked. Depending on what you do with the files, in extreme cases this may lead to buffer overflow attacks against you or your users. You should try to determine the MIME type yourself, for example using the Finfo functions.

like image 26
deceze Avatar answered Nov 11 '22 01:11

deceze