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.

== ARGUMENTS ==

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

There are two required parameters:

destinationURL
The destination where all files are uploaded.

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

Remember to urlencode both values.

Example:

<SEE THE INSTALL FILE IN THE ARCHIVE>

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.


== COMPILING ==

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


== CONTACT ==

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.

UPDATE

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.

14 thoughts on “Swoooosh – Free Open Source Flash-based Multi File Uploader”

  1. Pingback: | Mats Lindh
  2. Hi, nothing much happens behinde the scenes. The $_FILES-array in PHP will contain a field named Filedata that contains the regular fields for a file upload.

    A simple example of how to handle all submitted files is something like this (you should never store files directly available through the webserver, and you should never use the name submitted by the user (in the name field of $_FILES[‘Filedata’]).

    Here’s a simplified version (the PHP script isn’t invoked until the upload is done anyways):

  3. Hi,

    I’ve currently left the project “as it is”, since we’ve moved on to use one of the free upload applications that i mention in my post at:

    http://e-mats.org/2008/06/free-flash-based-file-upload-applications/

    They’re based on javascript and flash together, and works quite good. You are of course free to use the code from Swoooosh for anything you want, and if you make any vital updates, I’ll be happy to provide a link or host the file here.

  4. Could you send me the hole content of test.php?!

    I added the regular fields and the $_FILES arraies but nothing happens…
    Hope you can help me through that.

  5. Hi – I was wondering if you would be able to implement this for my site? I had someone due a file upload for me and they used Java. Which is fine if you aren’t using IE. I am not a code guy so all of this is pretty foreign to me. I can trade services with you if you would like. We have a business card print shop and I can print you 1000 glossy cards for your time. Let me know if you are interested. I would love to see this on the site! Thanks.

    Dan

  6. Hi, as I answered on E-mail, I don’t have any time to do “free” work at the moment, but if anyone else reading this blog is interested, they can leave a message with a working E-mail address and I’ll E-mail your contact address to them. Anyone interested can also follow the link on the previous poster.

  7. SwfUpload has been causing people fits since the release of flash 10 ….and I think the yahoo uploader was implementing it also. I have not kept up with the development of those projects to know if fixes have come out yet since I was forced to leave swfupload and implement new solutions to my projects upon the release of flash 10. At that time they had no certain time to officially support beyond flash 9. Those issues are well documented on the swfupload forum as well as adobe forum if you are interested in researching.

    This project would be a good one to continue on with, especially since I have only seen one other free script from vixiom which actually performs concurrent uploads.

  8. SWFUpload 2.2.0 (currently in beta 3) added support for Flash 10 – and after a bit of tinkering we got it to work in the development version of one of our projects. I made a small post about upgrading to SWFUpload 2.2.0 beta detailing my experiences with that version.

    Adding parallell uploads shouldn’t be too hard, and as this flash uploader actually shows a flash button as part of the process (as it’s implemented purely in flash, and not dependent on javascript living in the browser), it should work just fine in Flash 10. Feel free to extend it further and submit a patch. There isn’t much code, so getting the grip of it should be pretty easy.

  9. I really like the simplicity and ease of use of this – there’s just one thing I’d love to see implemented (if it hasn’t been already) – if there is an error uploading (or if your script rejects the file), then it would be nice to be able to pass that on to the ‘done’ page so it could display a message accordingly.

    Eg: my script is for uploading an image, so it would be nice if I could flag if someone tries to upload a .exe file and warn them on the ‘done’ page that it wasn’t accepted. At present, it disregards the file (as it isn’t an image), but redirects to the done page which has no idea, so just says ‘thanks, your file was received’…

    Other than that, fantastic :)

  10. How about file size limit? I have found that using Flex to upload the file size limit tends to be around 1 or 2 hundred MB, anyone found away around that?

Leave a Reply

Your email address will not be published. Required fields are marked *