File.name

Returns the name of the file. For security reasons, the path is excluded from this property.

Syntax

var name = instanceOfFile.name

Value

A string.

Example

// fileInput is a HTMLInputElement: <input type="file" multiple id="myfileinput">
var fileInput = document.getElementById("myfileinput");

// files is a FileList object (simliar to NodeList)
var files = fileInput.files;

for (var i = 0; i < files.length; i++) {
  alert("Filename " + files[i].name);
}

Specifications

Specification Status Comment
File API
The definition of 'name' in that specification.
Working Draft Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
File.name 13.0 3.6 (1.9.2) 10.0 16.0 Not supported
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
File.name Not supported Not supported Not supported Not supported Not supported

See also

Document Tags and Contributors

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