Web/API/File/name

From Get docs
< Web/API‎ | File


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 APIThe definition of 'name' in that specification. Working Draft Initial definition.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
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

Full support 4

Opera Android

No support No

Safari iOS

Full support 8

Samsung Internet Android

Full support Yes

Legend

Full support  
Full support
No support  
No support


See also