W3cubDocs

/DOM

DataTransferItem

The DataTransferItem object represents one drag data item. During a drag operation, each drag event has a dataTransfer property which contains a list of drag data items. Each item in the list is a DataTransferItem object.

This interface has no constructor.

Properties

DataTransferItem.kind Read only
The kind of drag data item, string or file.
DataTransferItem.type Read only
The drag data item's type, typically a MIME type.

Methods

DataTransferItem.getAsFile()
Returns the File object associated with the drag data item (or null if the drag item is not a file).
DataTransferItem.getAsString()
Invokes the specified callback with the drag data item string as its argument.
DataTransferItem.webkitGetAsEntry()
Returns an object based on FileSystemEntry representing the selected file's entry in its file system. This will generally be either a FileSystemFileEntry or FileSystemDirectoryEntry object.

Example

All of this interface's methods and properties have their own reference page, and each reference page has an example of its usage.

Specifications

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 4 Yes 50 No 12 No
getAsFile 4 Yes 50 No 12 No
getAsString 4 Yes 50 No 12 No
kind 4 Yes 50 No 12 No
type 4 Yes 50 No 12 No
webkitGetAsEntry 13 Yes 50 No No No
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support Yes Yes ? 50 No No ?
getAsFile Yes Yes ? 50 No No ?
getAsString Yes Yes ? 50 No No ?
kind Yes Yes ? 50 No No ?
type Yes Yes ? 50 No No ?
webkitGetAsEntry No Yes No 50 No No ?

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem