MIME type detection in Internet Explorer
I am now trying to code to detect the MIME types of a client on his machine. I am assuming that the client must be using Internet Explorer and so the code would be IE specific. What is the best method to know the MIME type of a user having Internet Explorer? Do you know any similar way to obtain this information?
Re: MIME type detection in Internet Explorer
The purpose of MIME type detection, or data sniffing, is to determine the MIME type of downloaded content using information from the following four sources:
- The server-supplied MIME type, if available
- An examination of the actual contents associated with a downloaded URL
- The file name associated with the downloaded content (assumed to be derived from the associated URL)
- Registry settings (file extension/MIME type associations or registered applications) in effect during the download
Re: MIME type detection in Internet Explorer
Internet Explorer already have the feature to detect MIME type from file on server sending to browser by using FindMimeFromData method. While uploading files from the client computer to the Web server, IE uses FindMimeFromData to determine a MIME type. FindMimeFromData returns a hard-coded values from its list of Known MIME Types rather than relying on the MIME type value associated with the file extension in the system registry.
Re: MIME type detection in Internet Explorer
You can even try out Drupal's MimeDetect to detect the MIME type. MimeDetect provides an API for consistent server side mime detection using the PHP FileInfo extension, the UNIX 'file' command, user supplied mime data, or file extension lookups. It is distributed with it's own magic library for use with the PHP FileInfo extension to make mime detection more consistent in different environments.