File
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
Note: This feature is available inWeb Workers.
TheFile interface provides information about files and allows JavaScript in a web page to access their content.
File objects are generally retrieved from aFileList object returned as a result of a user selecting files using the<input> element, or from a drag and drop operation'sDataTransfer object.
AFile object is a specific kind ofBlob, and can be used in any context that a Blob can. In particular, the following APIs accept bothBlobs andFile objects:
FileReaderURL.createObjectURL()Window.createImageBitmap()andWorkerGlobalScope.createImageBitmap()- the
bodyoption tofetch() XMLHttpRequest.send()
SeeUsing files from web applications for more information and examples.
In this article
Constructor
File()Returns a newly constructed
File.
Instance properties
TheFile interface also inherits properties from theBlob interface.
File.lastModifiedRead onlyReturns the last modified time of the file, in millisecond since the UNIX epoch (January 1st, 1970 at Midnight).
File.lastModifiedDateDeprecatedRead onlyNon-standardReturns the last modified
Dateof the file referenced by theFileobject.File.nameRead onlyReturns the name of the file referenced by the
Fileobject.File.webkitRelativePathRead onlyReturns the path the URL of the
Fileis relative to.
Instance methods
TheFile interface also inherits methods from theBlob interface.
Specifications
| Specification |
|---|
| File API> # file-section> |