Name

File — a file in the local filesystem

Inherits from

Blob

Synopsis

A File is a Blob that has a name and possibly also a modification date. It represents a file in the local file system. Obtain a user-selected file from the files array of an <input type=file> element, or from the files array of the DataTransfer object associated with the Event object that accompanies a drop event.

You can also obtain File objects that represent files in a private, sandboxed filesystem, as described in The Filesystem API. The filesystem API is not stable at the time of this writing, however, and it is not documented in this reference section.

You can upload the contents of a file to a server with a FormData object or by passing the File to XMLHttpRequest.send(), but there is not much else you can do with the File object itself. Use FileReader to read the contents of a File (or of any Blob).

Properties

readonly Date lastModifiedDate

The modification date of the file, or null if it is not available.

readonly string name

The name of the file (but not its path).

Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.