Drag and Drop of file upload in DOJO
Is there an option in DOJO where files can be uploaded by Drag and开发者_C百科 Drop from desktop to the browser?
No I dont believe so. As outlined here and here its not really possible to do without using a plugin.
Old post, but still one of those posts being found by google easily. For those interested how to do this:
- Have a look at this SO answer
- Dojo overview of how to use its Uploader (styled as a button)
- Use
addDropTarget
to link a dropArea for that uploader (for HTML5-enabled browsers -- see also first link)) - To make the drop target visibly react to drag events, I had to connect directly to browser events like
ondragenter
orondragleave
(see code snippet below)
createUploader: function() {
// ... define uploader and droptarget
d_on(this.dropArea, "dragover", d_lang.hitch(this, this.dropAreaOver));
d_on(this.dropArea, "dragleave", d_lang.hitch(this, this.dropAreaLeave));
d_on(this.dropArea, "drop", d_lang.hitch(this, this.dropAreaLeave));
}
dropAreaOver: function(evt) {
evt.preventDefault();
domClass.add(this.dropArea, "dropAreaOver");
},
dropAreaLeave: function(evt) {
evt.preventDefault();
domClass.remove(this.dropArea, "dropAreaOver");
}
精彩评论