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
객체가 나타내는 파일의 이름을 반환합니다. 보안상의 이유로 경로는 이름에서 제외됩니다.
값
"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.