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 in Web Workers.
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 Blobs and File objects:
FileReaderURL.createObjectURL()Window.createImageBitmap() and WorkerGlobalScope.createImageBitmap()
body option to fetch()
XMLHttpRequest.send()See Using files from web applications for more information and examples.
File()Returns a newly constructed File.
The File interface also inherits properties from the Blob interface.
File.lastModified Read only
Returns the last modified time of the file, in millisecond since the UNIX epoch (January 1st, 1970 at Midnight).
File.lastModifiedDate Deprecated Read only Non-standard
Returns the last modified Date of the file referenced by the File object.
File.name Read only
Returns the name of the file referenced by the File object.
File.webkitRelativePath Read only
Returns the path the URL of the File is relative to.
The File interface also inherits methods from the Blob interface.
| Specification |
|---|
| File API> # file-section> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
File |
38 | 79 | 28 | 25 | 10.1 | 38 | 28 | 25 | 10.3 | 3.0 | 38 | 10.3 |
File |
13 | 12 | 73–7Non-standard implementation. |
11.5 | 4 | 18 | 74–7Non-standard implementation. |
11.5 | 3.2 | 1.0 | 4.4 | 3.2 |
lastModified |
13 | 18 | 15 | ≤15 | 10 | 18 | 15 | ≤14 | 10 | 1.0 | 4.4 | 10 |
lastModifiedDate |
13 | 12 | 15–61 | ≤15 | 7–10 | 18 | No | ≤14 | 7–10 | 1.0 | 4.4 | 7–10 |
name |
13 | 12 | 3.6 | ≤15 | 8 | 18 | 4 | ≤14 | 8 | 1.0 | 4.4 | 8 |
webkitRelativePath |
13 | 13 | 50 | 15 | 11.1 | 18 | 142141–142Always an empty string (bug 1973726). |
14 | 11.3 | 1.0 | 4.4 | 11.3 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/File