aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/file/name/index.html
blob: a43ef5913b69285896631980773056c273251b45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
---
title: File.name
slug: Web/API/File/name
translation_of: Web/API/File/name
---
<p>{{APIRef("File API")}}</p>

<h3 id="概述">概述</h3>

<p>返回文件的名称.由于安全原因,返回的值并不包含文件路径.</p>

<h3 id="示例">示例</h3>

<pre class="brush:js">// fileInput is a HTMLInputElement: &lt;input type="file" multiple id="myfileinput"&gt;
var fileInput = document.getElementById("myfileinput");

// files is a FileList object (simliar to NodeList)
var files = fileInput.files;

for (var i = 0; i &lt; files.length; i++) {
  alert("Filename " + files[i].name);
}</pre>