Blob.size

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

Blob 인터페이스의 size 속성은 Blob 또는 File의 크기를 바이트 단위로 반환합니다.

Blob 또는 File과 같은 Blob 기반 객체의 데이터 크기를 바이트 단위로 나타낸 숫자입니다.

예제

이 예제는 file 유형의 <input> 요소를 통해 사용자가 선택한 여러 파일을 순회하면서, 각각의 파일 이름과 바이트 크기를 출력합니다.

HTML

html
<input type="file" id="input" multiple />
<output id="output">파일 선택...</output>

JavaScript

js
const input = document.getElementById("input");
const output = document.getElementById("output");

input.addEventListener("change", (event) => {
  output.innerText = "";

  for (const file of event.target.files) {
    output.innerText += `${file.name}의 크기는 ${file.size} 바이트입니다.\n`;
  }
});

결과

명세

Specification
File API
# dfn-size

브라우저 호환성

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
size

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Has more compatibility info.

같이 보기