Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

JavaScript | WebAPI | File | File.type Property

  • Last Updated : 18 Jan, 2019

The File.type property is an inbuilt function of File WebAPI which gives the media type (MIME) of the file represented by a file object.


Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

var name = file.type;

Return Value: It returns a string containing media type (MIME) indicating the type of the file. For example: “image/png” for PNG images.


<!DOCTYPE html>
        WebAPI File.type
        #test {
            padding: 10px;
            width: 300px;
            border: 1px solid green;
    <div id = "test">
        <input type = "file" multiple onchange
                = "myGeeks(this)">
    <script type = "text/javascript">
        function myGeeks(fileInput) {
        var files = fileInput.files;
            for (var i = 0; i < files.length; i++) {
                var file_name = files[i].name;
                var file_type = files[i].type;
                alert("Filename: " + file_name
                    + ", Type: " + file_type);


Supported Browsers: The browser supported by WebAPI File.type property are listed below:

  • Edge
  • Google Chrome 13.0
  • Firefox 3.6
  • Opera 16.0
  • Internet Explorer 10.0
  • Safari


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!