I haven't seen any good file upload component for OpenLaszlo. Is there an open source version of a file upload component, which supports drag & drop for DHTML and Adobe AIR, and a preview functionality for both runtimes?
Technically it is possible to support the following features:
- drag and drop file upload in DHTML for all desktop browsers http://caniuse.com/#feat=dragndrop
- preview of images for Webkit browsers and Firefox in DHTML, and for all browsers using a SWF runtime
- drag and drop support for Adobe Air applications
Maybe someone has an existing component which could be made open source, and maintained or improved by the community.
There is currently no way to do a File Upload in DHTML (aka HTML5) mode of an OpenLaszlo application since unfortunately there is no way to set the form type to enctype=multipart/form-data in that run-time.
However, you can do a File Upload with the SWF(Flash) mode of an OpenLaszlo application by accessing the low-level Flash API. It is not obvious how to do this so I wrote a class to do this myself a while back, it will work under (Flash) SWF8, SWF9 and SWF10 mode of OpenLaszlo.
I have never tried compiling an OpenLaszlo application to AIR but I believe the Flash Upload will probably work for that case too.
Here is my class, feel free to use it:
( The code is also avaiable here: http://forum.openlaszlo.org/showthread.php?t=14566&highlight=fileReference )
Note: This works similar to an HTML form where you post the file upload to a receiving script on the backend (could be in PHP, ASP, etc.) which would process the file and store it somewhere, there are many tutorials on the web on how to do that so I have not included it. As for drag and drop and preview you would have to write a fairly complicated application in OpenLaszlo yourself to do this, I suggest you view the tutorials and OpenLaszlo documentation to learn how to do that.