Blob.size
The Blob
interface's size
property returns the size of the Blob
or File
in bytes.
Syntax
var sizeInBytes = blob.size
Value
The number of bytes of data contained within the Blob
(or Blob
-based object, such as a File
).
Example
This example uses an <input>
element of type file
to ask the user for a group of files, then iterates over those files outputting their names and lengths in bytes.
// fileInput is a HTMLInputElement: <input type="file" multiple id="myfileinput"> var fileInput = document.getElementById("myfileinput"); // files is a FileList object (similar to NodeList) var files = fileInput.files; for (var i = 0; i < files.length; i++) { console.log(files[i].name + " has a size of " + files[i].size + " Bytes"); }
Specifications
Specification |
---|
File API # dfn-size |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
size |
5 |
12 |
4 |
10 |
11 |
5.1 |
≤37 |
18 |
No |
No |
No |
1.0 |
See also
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Blob/size