Your Search Results



    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.


    var mimetype = instanceOfFile.type


    A string


    // fileInput is a HTMLInputElement: <input type="file" multiple id="myfileinput">
    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.


    Specification Status Comment
    File API
    The definition of 'type' in that specification.
    Working Draft Initial definition.

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit) 5 Unknown (4) 10.0 11.10 5.1
    Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile Not supported Not supported Not supported Not supported Not supported

    See also

    Document Tags and Contributors

    Last updated by: Jeremie,