Home

Awesome

datatransfer-files-promise

Get a promise for a flat array of files from the 'drop' event, like <input type="file"/>.files.

Features

Usage:

const { getFilesFromDataTransferItems } = require('datatransfer-files-promise')

const dropzone = document.querySelector('.drop-area')
dropzone.addEventListener('dragover', evt => evt.preventDefault())
dropzone.addEventListener('drop', async evt => {
  evt.preventDefault()
  const files = await getFilesFromDataTransferItems(evt.dataTransfer.items)
  console.log('files', files)
  files.forEach((file, i) => {
    console.log(i, file.filepath)
  })
})

open example in browser