Is it possible to use jQuery’s drop event for dragging files from the desktop?
If so, how do I get the dropped file data?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s a little messy (you need to handle at least 3 events) but possible.
First, you need to add eventhandlers for
dragoveranddragenterand prevent the default actions for these events like that:It’s actually important to call
preventDefaulton these events, otherwise, some browsers may never trigger thedropevent.Then you can add the drop-handler and access the dropped files with
e.originalEvent.dataTransfer.files:Now you are able to drag files from the desktop/explorer/finder in the div and access them.
http://jsfiddle.net/fSA4N/5/