Diese Übersetzung ist unvollständig. Bitte helfen Sie, diesen Artikel aus dem Englischen zu übersetzen.
Summary
The type
property of a Blob
object provides the MIME type of the file. It returns an empty string if the type couldn't determined.
Syntax
var mimetype = instanceOfFile.type
Value
A string
Example
// fileInput is a HTMLInputElement: var fileInput = document.getElementById("myfileinput"); // files is a FileList object (simliar to NodeList) var files = fileInput.files; // our application only allows *.png, *.jpeg and *.gif images var allowedFileTypes = ["image/png", "image/jpeg", "image/gif"]; files.forEach( function (file) { // Test if file.type is an allowed file type. if (allowedFileTypes.indexOf(file.type) > -1) { // file type matched is one of allowed file types. Do something here. } });
Specifications
Specification | Status | Comment |
---|---|---|
File API Die Definition von 'type' in dieser Spezifikation. |
Arbeitsentwurf | Initial definition. |
Browser compatibility
Wir konvertieren die Kompatibilitätsdaten in ein maschinenlesbares JSON Format. Diese Kompatibilitätstabelle liegt noch im alten Format vor, denn die darin enthaltenen Daten wurden noch nicht konvertiert. Finde heraus wie du helfen kannst!
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
File.name | 5 | Unknown (4) | 10.0 | 11.10 | 5.1 |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
File.name | Nicht unterstützt | Nicht unterstützt | Nicht unterstützt | Nicht unterstützt | Nicht unterstützt |