Swoooosh – Free Open Source Flash-based Multi File Uploader

As I’ve mentioned a few times before I’ve been playing around with Adobe Flex. I finally got some more time to play with it tonight, so I got everything together to a semi-usable shape. A few things are still missing, such as moving the active uploads to the top and handling more than a total number of x queued uploads (at a certain level the progress bars will just disappear out of the Flash area, then magically appear as enough other items are finished).

Download Swoooosh.tar.bz2!

I’m looking for any response on this, and if anyone want to play around with it, please go ahead. It should be fairly simple to set up. I’ve included a brief description of the arguments it accepts below. Everything is released under a slightly modified MIT-based license, where the only change is that I’ve removed the need for keeping the copyright notice in anything that’s not the source code itself. Use it for anything you’d like, and if you make something useful, I’d be happy if you would contribute at patch back to me so that I could update the library itself.

You can see the application in action at my test installation. I’ll remove this test later, and be advised that the files actually will be transferred to my webserver. I’m just going to run rm -f * anyways, but if anyone breaks in and steals your precious uploaded files, you’re the one to blame.


The arguments to the flash file are provided in the flashVars attribute.

There are two required parameters:

The destination where all files are uploaded.

The URL the client is redirected to when all files have been uploaded.

Remember to urlencode both values.



Optional parameters that are available is:

progressIndicatorColor: "#bfbfbf"
The color of the progress bar.

progressIndicatorBackgroundColor: "white"
The color of the empty bar before any progress has been made.

progressIndicatorWidth: 300
The width of the progress bar indicator.

uploadButtonText: "Click here to upload files!"
The text of the button the user has to click to start uploading files.


To compile the SWF-file from the source code, download the Adobe Flex 3 SDK,
then run mxmlc against Swoooosh/Swoooosh.mxml:

mxmlc Swoooosh/Swoooosh.mxml


Any and all comments are welcome. See the included LICENSE file for
information about usage. Short words: do whatever you want, just don't
claim you wrote it without contributing.

All patches are of course welcome.


As I’ve received many comments about the contents of test.php (the file that receives the post), here is the smallest version:

if (is_array($_FILES))
    foreach($_FILES as $file)
        file_put_contents('directory_name_to_write_files_to/' . uniqid(), file_get_contents($file['tmp_name']));

This will simply loop through all submitted files and write them to the temporary directory. As with other file uploads in PHP, you can access the original name of the file with the ‘name’ element in the $file array. DO NOT USE FILE NAME FROM ‘name’ WHEN WRITING THE FILE TO DISK. DOING THAT IS A VERY BAD IDEA, AS IT ALLOWS PEOPLE TO CREATE ANY FILE WITH ANY NAME (INCLUDING PHP-FILES WHICH CAN BE RUN IF THEY’RE AVAILABLE THROUGH THE WEB SERVER. YEP.). CAPS OFF.

Remember to make the directory you’re saving the files in WRITABLE for the process that writes the files (might be www-data or whatever user your webserver is running under). If you want to debug the response from the server regardless of what’s shown in the flash UI, use Wireshark to see the raw contents of packets and the conversions between the client and the server.

Changing Styles in Adobe Flex

Just a simple note for anyone trying to change the style properties of an element in Adobe Flex: use the .setStyle method on the element you want to change:

progress.setStyle("paddingRight", (event.bytesLoaded / event.bytesTotal) * 300);

And on the same track: If you want to place the items in a box close together, simply use the horizontalGap and verticalGap attributes on the mx:Box element to remove any spacing between the UI elements.

Exploring Adobe Flex For The First Time

Adobe Flex is an SDK from Adobe for creating Flash applications based on XML and ActionScript. No need for Flash MX or Flash CS3, just markup, markup, markup and some ECMA-script thrown in for making it all come together. While I’m no fan of flash content on sites, this adventure has it’s purpose: making an open source multifile upload application. Every now and then I run into the need for allowing people to upload several files at once (think 20 – 100 files), and selecting each by itself would be really tiresome. The only good solution I’ve come across so far is the flash based uploaders, so well, here we go. The plan is to release the result under a MIT-based license.

Flex has been quite good to me so far. The UI of the application is built as a XML file, and the code is simply added as ActionScript in a CDATA-section in the XML-file. Simple. You then run the XML-file (MXML) through a compiler (mxmlc) and get a ready-to-run .swf file out. Works like a charm.