File
BaselineWidely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
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 bothBlob
s andFile
objects:
FileReader
URL.createObjectURL()
Window.createImageBitmap()
andWorkerGlobalScope.createImageBitmap()
- the
body
option tofetch()
XMLHttpRequest.send()
SeeUsing files from web applications for more information and examples.
Constructor
File()
Returns a newly constructed
File
.
Instance properties
TheFile
interface also inherits properties from theBlob
interface.
File.lastModified
Read onlyReturns the last modified time of the file, in millisecond since the UNIX epoch (January 1st, 1970 at Midnight).
File.lastModifiedDate
DeprecatedRead onlyNon-standardReturns the last modified
Date
of the file referenced by theFile
object.File.name
Read onlyReturns the name of the file referenced by the
File
object.File.webkitRelativePath
Read onlyReturns the path the URL of the
File
is relative to.
Instance methods
TheFile
interface also inherits methods from theBlob
interface.
Specifications
Specification |
---|
File API # file-section |