File: name プロパティ
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.
メモ: この機能はウェブワーカー内で利用可能です。
name
は File
インターフェイスの読み取り専用プロパティで、この File
オブジェクトによって表されるファイルの名前を返します。セキュリティ上の理由から、パスはこのプロパティから除外されます。
値
パスを除いたファイル名の入った文字列。 "My Resume.rtf" など。
例
HTML
html
<input type="file" id="filepicker" multiple />
<div>
<p>選択されたファイルのリスト:</p>
<ul id="output"></ul>
</div>
JavaScript
js
const output = document.getElementById("output");
const filepicker = document.getElementById("filepicker");
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);
}
});
結果
仕様書
Specification |
---|
File API # dfn-name |
ブラウザーの互換性
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.