--- title: File.name slug: Web/API/File/name translation_of: Web/API/File/name ---
{{APIRef("File API")}}
返回文件的名称.由于安全原因,返回的值并不包含文件路径.
// fileInput is a HTMLInputElement: <input type="file" multiple id="myfileinput"> var fileInput = document.getElementById("myfileinput"); // files is a FileList object (simliar to NodeList) var files = fileInput.files; for (var i = 0; i < files.length; i++) { alert("Filename " + files[i].name); }