File: name-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 name
-Schreibgeschützte Eigenschaft des File
-Interface gibt den Namen der Datei zurück, die durch ein File
-Objekt dargestellt wird. Aus Sicherheitsgründen ist der Pfad in dieser Eigenschaft ausgeschlossen.
Wert
Ein String, der den Namen der Datei ohne Pfad enthält, wie zum Beispiel "Mein Lebenslauf.rtf".
Beispiele
HTML
html
<input type="file" id="file-picker" multiple />
<div>
<p>List of selected files:</p>
<ul id="output"></ul>
</div>
JavaScript
js
const output = document.getElementById("output");
const filePicker = document.getElementById("file-picker");
filePicker.addEventListener("change", (event) => {
const files = event.target.files;
output.textContent = "";
for (const file of files) {
const li = document.createElement("li");
li.textContent = file.name;
output.appendChild(li);
}
});
Ergebnis
Spezifikationen
Specification |
---|
File API # dfn-name |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Has more compatibility info.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.