DataTransfer: files property

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.

The files read-only property of DataTransfer objects is a list of the files in the drag operation. If the operation includes no files, the list is empty.

This feature can be used to drag files from a user's desktop to the browser.

Note: The files property of DataTransfer objects can only be accessed from within the drop event. For all other events, the files property will be empty — because its underlying data store will be in a protected mode.

Value

A list of the files in a drag operation, one list item for each file in the operation. If the drag operation had no files, the list is empty.

Examples

There are two live examples of this interface:

Specifications

Specification
HTML
# dom-datatransfer-files-dev

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
files

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support