How do I determine the MIME of a file?

How do I determine the MIME of a file?

The most simple way to detect the MIME type of any file is to use MIME_Type’s static autoDetect() method. It will try to determine the file’s type and return it as a string. If an error occurs, a PEAR_Error object is returned.

What is the MIME type for Excel file?

File extensions and mime types of previewed files

Extension Mime type
xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
xlsb application/vnd.ms-excel.sheet.binary.macroEnabled.12
xls application/vnd.ms-excel
xlsm application/vnd.ms-excel.sheet.macroEnabled.12

What is the MIME type for text file?

Common MIME types

Extension Kind of document MIME Type
.txt Text, (generally ASCII or ISO 8859-n) text/plain
.vsd Microsoft Visio application/vnd.visio
.wav Waveform Audio Format audio/wav
.weba WEBM audio audio/webm

What are the Microsoft Office MIME types?

What are the Microsoft Office MIME Types?

Ext MIME Type
.dot application/msword
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template
.docm application/vnd.ms-word.document.macroEnabled.12

Where is MIME type stored?

All MIME type information is stored in a database. The MIME database is located in the directory /usr/share/mime/ . The MIME database contains a large number of common MIME types, stored in the file /usr/share/mime/packages/freedesktop.

How to guess MIME type by file extension?

Guessing of MIME types by file extension. Uses a static list of file-extension : MIME type mappings. ( x.y. [z + 1]) releases to be as correct as possible. Additionally, only the extensions of paths/filenames are inspected in order to guess the MIME type.

Are there any security exploits for guessing MIME types?

MIME type guessing has led to security exploits in Internet Explorer that were based upon a malicious author incorrectly reporting a MIME type of a dangerous file as a safe type. This bypassed the normal download dialog, resulting in Internet Explorer guessing that the content was an executable program and then running it on the user’s computer.

Which is the best definition of mime guess?

An iterator over the Mime types of a MimeGuess. An iterator over the raw media type strings of a MimeGuess. A parsed mime or media type. A “guess” of the MIME/Media Type (s) of an extension or path as one or more Mime instances.

How to guess the extension of a file?

Guess the extension for a file based on its MIME type, given by type. The return value is a string giving a filename extension, including the leading dot ( ‘.’ ). The extension is not guaranteed to have been associated with any particular data stream, but would be mapped to the MIME type type by guess_type ().