DataTransfer: files property
{{APIRef("HTML Drag and Drop API")}}
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 ofDataTransfer
objects can only be accessed from within thedrop
event. For all other events, thefiles
property will be empty — because its underlying data store will be in a protected mode.
Value
A {{domxref("FileList","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:
- Firefox only: https://jsfiddle.net/9C2EF/
- All browsers: https://jsbin.com/hiqasek/
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}