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

JavascriptHtmlDrag and-Drop

Javascript Problem Overview


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-drop HTML5 API just yet and am still a little foggy on it. I'm working on it at my site. If you wouldn't mind poking around my code and seeing what's going on, it would be highly appreciated. The entire event object is being logged.

Javascript Solutions


Solution 1 - Javascript

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

function onDrop(event) {
    event.preventDefault();
    console.log(event.dataTransfer.files[0]);
}

Solution 2 - Javascript

Also take a look at this bug/behavior: https://stackoverflow.com/questions/8414154/

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

Solution 3 - Javascript

I found what I needed in:

e.originalEvent.dataTransfer

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionnkcmrView Question on Stackoverflow
Solution 1 - JavascriptEsailijaView Answer on Stackoverflow
Solution 2 - JavascriptWFWView Answer on Stackoverflow
Solution 3 - JavascriptAndrewView Answer on Stackoverflow