This page was translated from English by the community. Learn more and join the MDN Web Docs community.
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 2015년 7월.
값
Blob 또는 File과 같은 Blob 기반 객체의 데이터 크기를 바이트 단위로 나타낸 숫자입니다.
예제
이 예제는 file 유형의 <input> 요소를 통해 사용자가 선택한 여러 파일을 순회하면서, 각각의 파일 이름과 바이트 크기를 출력합니다.
HTML
html
<input type="file" id="input" multiple />
<output id="output">파일 선택...</output>
output {
display: block;
margin-top: 16px;
}
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> |
브라우저 호환성
Enable JavaScript to view this browser compatibility table.