GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

File

File API

File API

The **`File`** interface provides information about files and allows JavaScript in a web page to access their content.

`File` objects are generally retrieved from a FileList object returned as a result of a user selecting files using the input element, or from a drag and drop operation's DataTransfer object.

A `File` object is a specific kind of Blob, and can be used in any context that a Blob can. In particular, the following APIs accept both `Blob`s and `File` objects:

- FileReader
- URL.createObjectURL()
- Window.createImageBitmap() and WorkerGlobalScope.createImageBitmap()
- the [`body`](/docs/Web/API/RequestInit#body) option to fetch()
- XMLHttpRequest.send()

See [Using files from web applications](/docs/Web/API/File_API/Using_files_from_web_applications) for more information and examples.

## Constructor

- File()
- : Returns a newly constructed `File`.

## Instance properties

_The `File` interface also inherits properties from the Blob interface._

- File.lastModified
- : Returns the last modified time of the file, in millisecond since the UNIX epoch (January 1st, 1970 at Midnight).
- File.lastModifiedDate
- : Returns the last modified Date of the file referenced by the `File` object.
- File.name
- : Returns the name of the file referenced by the `File` object.
- File.webkitRelativePath
- : Returns the path the URL of the `File` is relative to.

## Instance methods

_The `File` interface also inherits methods from the Blob interface._

## Specifications

## Browser compatibility

## See also

- [Using files from web applications](/docs/Web/API/File_API/Using_files_from_web_applications)
- FileReader

source: MDN Web Docs mirror · page

Cite this

"File". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/File

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·