File.name

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

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
nameChrome Full support 13Edge Full support 12Firefox Full support 3.6IE Full support 10Opera Full support 16Safari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android Full support Yes

Legend

Full support
Full support
No support
No support

See also