Skip to content. | Skip to navigation

Four Digits | Jansbinnensingel 26, 6811 AL Arnhem, The Netherlands | info@fourdigits.nl
 
Rob Gietema is one of the CEOs of Four Digits and a Zope developer for eight years. Rob was responsible for creating the front-end including the WYSIWYG editor for Coherence 2 (a CMS based on Zope). At the moment Rob is a Plone developer and maintainer of the TinyMCE Editor Plone product and the Round About Plone product. He is also currently working on the new UI for Plone (Deco).
 

Drag and Drop Image Uploading using Deco

by Rob Gietema Nov 11, 2009

In the new beta versions of Firefox 3.6 drag and drop support for uploading files is added, see what Deco can do with this functionality.

After Alexander Limi showed me some demo's of the drag and drop upload functionality added in the new beta versions of Firefox 3.6 I just had to try to add it to the Deco UI. The demo's used a fixed area where images can be dropped. In Deco you want to specify exactly where you want the images to be and not an area. To determine where to drop images Deco uses the mousemove event, but this event is not available when the window doesn't have focus (like with dragging images into a browser) so some code needed to be rewritten to use the dragover event.

Another issue was the fact the demo's use the sendAsBinary method of the XMLHttpRequest object. This method only sends the binary data itself and adding other fields like filename is not possible. I fixed this issue by creating a form request in javascript so I can add multiple fields like filename etc. All the sourcecode can be found in the Plone SVN.

 

 

This demo shows a Finder window on the left with some pictures taken at the Plone Conference 2009 and the Deco UI on the right with some example text. First a single image is dragged into the browser. The image is put on the dropped location and a black mask and loading icon is added to the image. The image is now being uploaded to the server and once ready the server returns the url and some more properties in a json structure. The correct source url is then applied to the image object.

Multiple files is also supported. Each image will be uploaded to Plone and becomes a sepparate tile. After the images are uploaded the images can be rearanged using the standard drag and drop functionality of Deco.

Made by Four Digits based on Plone.
Made by Four Digits based on Plone.