Blob
接口的
size
property returns the size of the
Blob
or
File
以字节为单位。
var sizeInBytes = blob.size
The number of bytes of data contained within the
Blob
(或
Blob
-based object, such as a
File
).
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 (simliar 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");
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
文件 API
The definition of 'Blob.size' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
size
|
Chrome 5 | Edge 12 | Firefox 4 | IE 10 | Opera 11 | Safari 5.1 | WebView Android 不支持 No | Chrome Android 18 | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 1.0 |
完整支持
不支持