We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

File Redirect 1


The File interface provides information about -- and access to the contents of -- files.

These are generally retrieved from a FileList object returned as a result of a user selecting files using the <input> element, from a drag and drop operation's DataTransfer object, or from the mozGetAsFile() API on an HTMLCanvasElement.

The file reference can be saved when the form is submitted while the user is offline, so that the data can be retrieved and uploaded when the Internet connection is restored.


File.lastModifiedDate Read only
The last modified Date of the file referenced by the File object.
File.name Read only
The name of the file referenced by the File object.
File.fileName Read only Obsolete since Gecko 7.0
The name of the file referenced by the File object.
File.fileSize Read only Obsolete since Gecko 7.0
The size of the referenced file in bytes.


File.getAsBinary() Obsolete since Gecko 7.0
Returns a string containing the file's data in raw binary format.
File.getAsDataURL() Obsolete since Gecko 7.0
A string containing the file's data encoded as a data: URL.
File.getAsText(string encoding) Obsolete since Gecko 7.0
Returns the file's contents as a string in which the file's data is interpreted as text using a given encoding.

The File interface also inherits methods from the Blob interface.

Returns a new Blob object containing the data in the specified range of bytes of the source Blob.
Note: Be aware that the slice() method has vendor prefixes on some browsers and versions: blob.mozSlice() for Firefox 12 and earlier and blob.webkitSlice() in Safari. An old version of the slice() method, without vendor prefixes, had different semantics, and is obsolete. The support for blob.mozSlice() has been dropped with Firefox 30.


Specification Status Comment
File API Working Draft Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 13 3.0 (1.9) (non standard)
7 (7) (standard)
10.0 16.0 6.0
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
basic support Not supported 25 Not supported 11.1 6.0

Implementation notes

Gecko notes

  • In Gecko, you can use this API from chrome code. See Using the DOM File API in chrome code for details.
  • Starting in Gecko 6.0 (Firefox 6.0 / Thunderbird 6.0 / SeaMonkey 2.3), privileged code (such as extensions) can pass an nsIFile object to the DOM File constructor to specify the file to reference.
  • Starting in Gecko 8.0 (Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5), you can use new File to create File objects from XPCOM component code instead of having to instantiate the nsIDOMFile object directly.

See also

Document Tags and Contributors

Last updated by: Sheppy,