Nov 10 2009

Uploading Files Using Flash and Java

The sample code attached below is a complete example for uploading multiple files using flash cs3 and java. After much searching I could not find a complete Flash File uploading tutorial that utilized java; most if not all are for php. This flash interface provides progress for each file independently, and upon completion can notify a javascript function. The files are sent to a simple JAVA servlet where they are saved to the local file system.

For the java servlet there are two library requirements:
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar

They are included in the web/WEB-INF/lib folder. The source files are saved as a Netbeans 6.7 project with Glassfish set as the target server. It is simple to open the project and change the target server. Both the compiled flash and source file are in the web folder.

I extracted two settings to variables listed in the index.html file so that this could be used without recompiling/editing the flash file. The first variable url is the address of the java servlet to send the files to. The second variable is f  and is the name of the javascript function to call when each file is uploaded. f is optional. These variables need to be set 3 times in the index.html file. See the file for further documentation.

I expect to update the source code slightly over the next couple weeks. I will replace the zip file with the latest as updates are completed.

source files