Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

我們的志工尚未將此文章翻譯為 正體中文 (繁體) 版本。加入我們,幫忙翻譯!

The Blob.size property returns the size in bytes of the Blob or a File.

Syntax

var sizeInBytes = blob.size

Value

A number.

Example

// 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");
}

Specifications

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

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
File.size 5 4.0 (2) 10.0 11.10 5.1
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
File.size No support No support No support No support No support

See also

文件標籤與貢獻者

 此頁面的貢獻者: vinnymac, Nickolay, fscholz, Jeremie, Cobra, Sheppy, ethertank, ziyunfei, Crash
 最近更新: vinnymac,