Returns the name of the file represented by a
File
object. For security reasons, the path is excluded from this property.
var name = file.name;
A string, containing the name of the file without path, such as "My Resume.rtf".
<input type="file" multiple onchange="processSelectedFiles(this)">
function processSelectedFiles(fileInput) {
var files = fileInput.files;
for (var i = 0; i < files.length; i++) {
alert("Filename " + files[i].name);
}
}
Try the results out below:
| 规范 | 状态 | 注释 |
|---|---|---|
|
文件 API
The definition of 'name' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
名称
|
Chrome 13 | Edge 12 | Firefox 3.6 | IE 10 | Opera 16 | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android Yes |
完整支持
不支持
File