Dev UtilitiesLesson 133Free preview
MIME Type Lookup
This lesson is part of Web Developer Tools · All levels
Summary
MIME type lookup indicates the appropriate content type for a file extension, for example .html to text/html and .png to image/png. This type is sent to the server via the Content-Type header so that the browser knows how to display the file. Extension matching is important for asset presentation and validation of uploads. For security, check the contents of the file and don't just rely on the name of the extension.
Key points
- The common format of MIME is type/subtype, for example application/json
- Content-Type header tells the browser the type of data
- Charset parameters add encoding information to the text
- Validation of uploads requires content checking, not just extensions
- Use the standard MIME library instead of the manual list
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.