There are a lot of demos and tutorials that show you how to drag-and-drop a file into the browser and then render it on the page. This article is going to address how to bring the feature (Drag and Drop automatic file upload) into Liferay CMS and ForgeCart, a complete eCommerce solution.
Introduction
- Capture the drop event and read its data.
- Post that binary data to the server.
- Provide feedback on the progress of the upload.
- Optionally render a preview of what's being uploaded and its status.
- Drag and drop (DnD), a first class citizen in HTML5 - The specification defines an event-based mechanism, JavaScript API, and additional markup for declaring that just about any type of element be draggable on a page.
- FormData object represents an ordered collection of entries. Each entry has a name and value.
- XMLHttpRequest (XHR) is an API available in web browser scripting languages such as JavaScript. It is used to send HTTP or HTTPS requests directly to a web server and load the server response data directly back into the script.
- FileReader interface provides methods to read File objects or Blob objects into memory, and to access the data from those Files or Blobs using progress events and event handler attributes; it inherits from EventTarget. It is desirable to read data from file systems asynchronously in the main thread of user agents.
In CMS
JavaScript code snippet
Drag and drop, automatic file upload into Server Document and Media, integrated with Tree-View.

Online demo (Liferay Portal 6.1 GA2)
In ForgeCart

drag and drop , automatic file upload

Download


