SWFUpload

SWFUpload is a neat little tool that alows you to use Flash as a file uploader in your web forms. If your users have Flash, the script writes out a Flash uploader, and if they don’t, they get a nice HTML upload form field. Very nice, and it uses SWFObject for the plugin detection + embedding.

This is a great example of using Flash where Flash can do something better than HTML. And doing it in a way that uses progressive enhancement so it doesn’t require Flash. It’s just that Flash makes it better.

43 thoughts on “SWFUpload

  1. Yeah, you can use it with cold fusion, it comes through just like a normal file upload (not that I have tested it, this is just what I remember from reading up on the flash uploading functionality).

    You can still run into problems with file sizes however, so I wrote a FTP uploader if you need larger files. See my post here, you can download it from here.

    There is a demo in the zip file, actual documentation coming soon…

  2. wow, thanks, this is exactly what i was looking. great post. I also have coldfusion and was wondering about the same question from Marcio.

  3. If you could give me help I would appreciate it.
    http://www.revolvus.com/uploadtest/
    Try uploading a large file around 1 MB and it will error, but if I upload an image around 90 KB it works. This uploads to a PHP script and I have an htaccess file in the directory with the following settings:

    # These stop HTTP errors 403 & 406
    SecFilterEngine Off
    SecFilterScanPOST Off
    # Increase max upload size and timeout
    php_value upload_max_filesize “20M”
    php_value post_max_size “20M”
    php_value max_execution_time 900
    php_value max_input_time 1800

    You can visit http://www.revolvus.com/uploadtest/ to test it. If I use a PHP form it works fine. The whole reason I want flash is for the progress bar. Its much simpler then using AJAX or other methods which I really don’t wanna have to deal with.

  4. I can’t seem to get the progress bar part to work on my installation. Did you have to do anything special for it?

  5. SWF is neat by itself, but when I try to incorporate it with ASP.Net 2.0, it does not work because the Target DIVs are inside a FORM tag. The FORM tag is automatically generated by Visual Web Developer when you create a Web Control. In order for it to work you will have to put the target DIVs outside the FORM elements. Does anyone know how to make it work with the target DIVs inside FORM elements?

  6. @Niel
    I’m also trying to integrate SWFUpload in to ASP.Net 2.0. I’m having the same problem with the ASP.Net form. I think a pretty simple modification to the Javascript that generates the object tag will fix it. I’ll post my progress to my blog sometime next week.

    I also have trouble adding more than one SWFUpload to a page. Again I think a relatively simple change to the Javascript will fix this as well.

    It’d be nice to have someone maybe check out the FLA file and see if a fix is possible that won’t require the object tag to be placed outside a form.

  7. Anyone else not having the progress bar show up? Not sure what’s causing it when I’m copying the example exactly. Thanks for any help.

  8. Prototype is a Javascript Toolkit/Library found at http://prototype.conio.net/.
    It actually works with mootools (mootools.net) as well. It is because of the function definition on example.js. For some reason it doesn’t work but the two libraries mentioned above provide the same functionality.

  9. Got it working. My example.js looks like this:
    function $(id) {
    return document.getElementById(id);
    }

    // Default upload start function.
    uploadStart = function(fileObj) {

    $("filesDisplay").style.display = "block";

    var li = document.createElement("li");
    var txt = document.createTextNode(fileObj.name);

    li.className = "uploading";
    li.id = fileObj.name;

    var prg = document.createElement("span");
    prg.id = fileObj.name + "progress";
    prg.className = "progressBar"

    li.appendChild(txt);
    li.appendChild(prg);

    $("mmUploadFileListing").appendChild(li);

    }

    uploadProgress = function(fileObj, bytesLoaded) {
    var progress = $(fileObj.name + "progress");
    var percent = Math.ceil((bytesLoaded / fileObj.size) * 100)

    progress.style.background = "url(jscripts/SWFUpload/images/progressbar.png) no-repeat -" + (100 - percent) + "px 0";

    }

    uploadComplete = function(fileObj) {
    $(fileObj.name).className = "uploadDone";
    $(fileObj.name).innerHTML += " " + (Math.ceil(fileObj.size / 1000)) + " kb";
    }

    uploadQueueComplete = function(fileObj) {
    alert("Queue done - All files are uploaded!");
    }

    uploadCancel = function() {
    alert("You pressed cancel!");
    }

  10. Hi!

    Didn’t get it to work :-(

    @Robert
    What exactly did you do? I put the prototype.js into the /jscripts folder (together with example.js) and included it in the index.php, but it doesn’t work.

    @Randy
    Isn’t this the code that is submitted with the original zip-file? I have the same code here (at least I can’t see any differences) but – as mentioned above – it doesn’t work.

    Any help is really appreciated!

  11. I’ve made some modifications to the script which I’ve posted on my “blog”.

    I’ve fixed the ASP.Net Forms issue and I’ve re-structured the classes so you can include as many SWFUpload objects as you need. This is useful for loading different settings for different uploads.

    SWFUpload Revision at Line by Line

  12. looks great at first but when you want to do reallife stuff you cant.

    1. hardcoded paths in js file
    2. no cookies are sent when using the flash upload

  13. since weeks i get at http://swfupload.mammon.se/ only an error, has the url changed ?

    Site Temporarily Unavailable
    We apologize for the inconvenience. Please contact the webmaster/ tech support immediately to have them rectify this.

    error id: “bad_httpd_conf”

Comments are closed.