event.dataTransfer.files is empty when ondrop is fired?

前端 未结 3 1586
Happy的楠姐
Happy的楠姐 2020-12-08 06:33

Okay, I have an element set up to receive a file-drop event, but when I look in event.dataTransfer it is blank. I haven\'t gotten around to learning the drag-n-

相关标签:
3条回答
  • 2020-12-08 06:46

    Also take a look at this bug/behavior: HTML5 drop event doesn't work unless dragover is handled

    Basically, you need to handle hover/drag and specify a dropEffect

    0 讨论(0)
  • 2020-12-08 06:48

    I found what I needed in:

    e.originalEvent.dataTransfer
    
    0 讨论(0)
  • 2020-12-08 07:04

    It's working fine, it's just a bug with the console.

    function onDrop(event) {
        event.preventDefault();
        console.log(event.dataTransfer.files[0]);
    }
    
    0 讨论(0)
提交回复
热议问题