Blob: size-Eigenschaft
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.
Hinweis: Diese Funktion ist in Web Workers verfügbar.
Die size
Eigenschaft des Blob
-Interfaces gibt die Größe des Blob
oder File
in Bytes zurück.
Wert
Die Anzahl der Bytes der Daten, die im Blob
(oder einem auf Blob
basierenden Objekt, wie zum Beispiel einer File
) enthalten sind.
Beispiele
Dieses Beispiel verwendet ein <input>
-Element vom Typ file
, um den Benutzer nach einer Gruppe von Dateien zu fragen, und iteriert dann über diese Dateien, um ihre Namen und Längen in Bytes auszugeben.
HTML
<input type="file" id="input" multiple />
<output id="output">Choose files…</output>
JavaScript
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} has a size of ${file.size} bytes.\n`;
}
});
Ergebnis
Spezifikationen
Specification |
---|
File API # dfn-size |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
size |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Has more compatibility info.