Returns the name of the file represented by a File
object. For security reasons, the path is excluded from this property.
Syntax
var name = file.name;
Value
A string, containing the name of the file without path, such as "My Resume.rtf".
Example
<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:
Specifications
Specification | Status | Comment |
---|---|---|
File API The definition of 'name' in that specification. |
Working Draft | Initial definition. |
Browser compatibility
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.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
name | Chrome Full support 13 | Edge Full support 12 | Firefox Full support 3.6 | IE Full support 10 | Opera Full support 16 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android No support No | Opera Android No support No | Safari iOS No support No | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- No support
- No support