DataTransfer.files
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.
files
は DataTransfer
オブジェクトのプロパティで、ドラッグ操作中のファイルのリストです。操作にファイルが含まれていない場合、リストは空になります。
この機能を利用して、ユーザーのデスクトップからブラウザーにファイルをドラッグすることができます。
メモ: DataTransfer
オブジェクトの files
プロパティは、 drop
イベントの中からのみアクセスできます。それ以外のどのイベントでも、 files
プロパティは空になります。その基礎となるデータストアが保護モードになるからです。
返値
ドラッグ操作中のファイルのリストで、 1 つのリスト項目が 1 つのファイルを表します。操作にファイルが含まれていない場合、リストは空になります。
例
このインターフェイスには 2 つのライブ例があります。
- Firefox 専用: https://jsfiddle.net/9C2EF/
- すべてのブラウザー: https://jsbin.com/hiqasek/
仕様書
Specification |
---|
HTML # dom-datatransfer-files-dev |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
files |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.