Closed Bug 640534 Opened 14 years ago Closed 14 years ago

dataTransfer.files does not exist while dragover and dragenter

Categories

(Core :: DOM: Copy & Paste and Drag & Drop, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: zitronenleo, Unassigned)

Details

User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:2.0) Gecko/20100101 Firefox/4.0 Build Identifier: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:2.0) Gecko/20100101 Firefox/4.0 In the new DragnDrop API the dataTransfer.files variable is set to null while hovering a drop target with some local files - you can access it with the drop event. It should be available for dragenter and maybe also for dragover, so the developer of the site can forbid dropping files. Thank you and sorry for not speaking perfectly English, Leo Reproducible: Always
You want to search dataTransfer.type for "Files"[1]; you can't see the files themselves until the user drops the files for security reasons. [1] https://developer.mozilla.org/En/DragDrop/DataTransfer#types
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Component: General → Drag and Drop
OS: Windows Vista → All
Product: Firefox → Core
QA Contact: general → drag-drop
Hardware: x86_64 → All
Resolution: --- → INVALID
Version: unspecified → Trunk
So all I have to do is to call dataTransfer.types[0] to check whether files are dragged over? Thanks, I thought it must have been a bug because Chrome and Safari behave in a different way.. Best Regards, Leo
I think you want dataTransfer.types.contains("Files"), since it's not guaranteed to be the first type.
Though, .contains won't work in chrome. You'll want to loop through dataTransfer.types and test all of the types for "Files".
You need to log in before you can comment on or make changes to this bug.