Skip to content
Related Articles
Open in App
Not now

Related Articles

JavaScript | WebAPI | File | File.size Property

Improve Article
Save Article
  • Last Updated : 18 Jan, 2019
Improve Article
Save Article

The property is an inbuilt function of file WebAPI which gives the size of a file in bytes.


var size = instanceOfFile.size;

Return Value: It returns a number, containing the size of the file in bytes.


<!DOCTYPE html>
        #main {
            padding: 10px;
            width: 300px;
            border: 1px solid black;
    <div id = "main">
        <input type = "file" multiple id = "file_input"
            onchange = "myGeeks(this)">
    <script type="text/javascript">
        function myGeeks(fileInput) {
            // File input
            var fileInput = document.getElementById("file_input");
            var files = fileInput.files;
            for (var i = 0; i < files.length; i++) {
                alert(files[i].name + " has a size of "
                + files[i].size + " Bytes");


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

  • Edge
  • Google Chrome
  • Firefox
  • Opera
  • Internet Explorer
  • Safari


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!