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:
Specification | Status | Comment |
---|---|---|
File API The definition of 'name' in that specification. | Working Draft | Initial definition. |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
File.name | 13.0 | (Yes) | 3.6 (1.9.2) | 10.0 | 16.0 | (Yes) [1] |
Feature | Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
File.name | No support | (Yes) | No support | No support | No support | No support |
[1] WebKit bug 32912
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/File/name