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

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support13 Yes3.61016 Yes
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes Yes No No No ?

See also

Document Tags and Contributors

 Contributors to this page: fscholz, erikadoyle, Nickolay, Jeremie, teoli, iamanupmenon, ethertank, Sheppy, Crash
 Last updated by: fscholz,