DataTransfer.files
The DataTransfer.files property 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.
Syntax
dataTransfer.files;
Return 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.
Example
There are two live examples of this interface:
- Firefox only: https://jsfiddle.net/9C2EF/
- All browsers: https://jsbin.com/hiqasek/
Specifications
| Specification |
|---|
| HTML Standard (HTML) # dom-datatransfer-files-dev |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
files |
3 |
12 |
3.6 |
10 |
≤12.1 |
≤4 |
≤37 |
18 |
4 |
≤12.1 |
≤3 |
1.0 |
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/files