Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Note: This feature is available in Web Workers.
The type read-only property of the Blob interface returns the MIME type of the file.
Note: Based on the current implementation, browsers won't actually read the bytestream of a file to determine its media type. It is assumed based on the file extension; a PNG image file renamed to .txt would give "text/plain" and not "image/png". Moreover, blob.type is generally reliable only for common file types like images, HTML documents, audio and video. Uncommon file extensions would return an empty string. Client configuration (for instance, the Windows Registry) may result in unexpected values even for common types. Developers are advised not to rely on this property as a sole validation scheme.
A string containing the file's MIME type, or an empty string if the type could not be determined.
This example asks the user to select a number of files, then checks each file to make sure it's one of a given set of image file types.
| File API # dfn-type |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 26, 2024 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.