Other versions:

FancyUpload - Swiff meets Ajax (v2.0)

Project FancyUpload - Swiff meets Ajax Showcase Swiff meets Ajax for powerful and elegant uploads. FancyUpload is a file-input replacement which features an unobtrusive, multiple-file selection menu and queued upload with an animated progress bar. It is easy to setup, is server independent, completely styleable via CSS and XHTML and uses MooTools to work in all modern browsers.


Showcases

Outdated Version

Get the new FancyUpload 3.0! 3.0 is the current release (more stable, more showcases, more documentation) and it is compatible with 2.0 and 2.1 (Old versions are not maintained anymore!).

Previous Version

If you missed the link above, the previous FancyUpload for MooTools 1.11 is still available including example code and minor updates.

Features

  • Select and upload multiple files
  • Filter files by type in the select dialog
  • Optional Events to add your own behaviour
  • Show and filter useful file information before the upload starts
  • Limit uploads by file count and/or file size
  • Platform and server independent, just needs Flash 9+ (> 95% penetration)
  • Unobtrusive, since the element is replaced after the swf loaded successfully
  • Cancel running uploads, add files during upload
  • Everything is optional, documented and easy editable
  • New in 2.0
    • Get the server response after upload for showing additional informations or previewing the image, etc.
    • Shows the current upload speed and the time left
    • Send additional request data via GET or POST variables
    • Set the filename for the upload request

Compatibility

Fully compatible with all A-Grade Browsers (Internet Explorer 6+, Opera 9, Firefox 1.5+ and Safari 2+) with Adobe Flash 9 player.

How to use

Will be written for the final release, at this time the showcases are the best documentation.

Tips, Tricks and Quirks

How do I access the uploaded files?

Every upload, even with multiple files, results in one request. Access the uploaded file via

Filedata is the default value for the option fieldName, so you can change it. The submitted content-type is always “application/octet-stream”, so don’t trust it when you validate the file.

Flash-request forgets cookies and session ID

Flash FileReference is not an intelligent upload class, the request will not have the browser cookies, Flash saves his own cookies. When you have sessions, append them as get-data to the the URL (e.g. “upload.php?SESSID=123456789abcdef”). Of course your session-name can be different.

Are cross-domain uploads possible?

Forum solution, and FileReference docs:

For uploading and downloading operations, a SWF file can access files only within its own domain, including any domains that are specified by a cross-domain policy file. If the SWF that is initiating the upload or download doesn’t come from the same domain as the file server, you must put a policy file on the file server. More on security and link to cross-domain policies

FancyUpload does not load, the input element gets not replaced

Check in Firebug in Net/Flash that the SWF file loads correctly. If not double check your given options.

Uploads fail with 404 error code

Check your URL and better use an absolute upload URL.

IE takes the upload url relative to the swf, all other browsers relative to the html/current file. So the best solution is an absolute path for the option url or rather the form action. If you have problems with failed upload and 404 error codes, try an absolute url, in your form-action or url option when creating your FancyUpload instance.

Uploads fail with 406/403 error

From the swfupload documentation:

If you are using Apache with mod_security this will not work, you need to put the following in your .htaccess file to disable mod_security:

SecFilterEngine Off SecFilterScanPOST Off

Disabling mod_security isn’t allowed on some shared hosts, and only do this if you know what you are doing. This is due to a bug in the way that flash sends the headers back to the server according to the Flash 8 documentation

Uploads fail with 403/500 error

Check your server config, there must be something wrong. Also see 404, double check the upload URL.

Uploads and Basic Authentication

Flash does not care about authenticated Browsers. Firefix/Win/Flash 9 can handle it, IE too, Mac can’t handle it. Anyways, Flash will ask for its own access username and password.

Requirements

It does not depend on any server-side architecture or language.

MooTools JavaScript Framework 1.2

Download MooTools 1.2.

  • Element.Events
  • Fx.Tween
  • Fx.Transitions
  • Selectors
  • Json
  • Swiff
  • DomReady (facultative)

Don’t use compressed code during development to simplify debugging.

Download

Get the new FancyUpload 3.0! 3.0 is the current release (more stable, more showcases, more documentation) and it is compatible with 2.0 and 2.1 (Old versions are not maintained anymore!).

References

Changelog

3.0 (2009-05-25)
  • Added: Option timeLimit (default 30s, 0 for linux). Prevents frozen upload when server fails, after timeout the upload is cancelled and the complete event fired (with “timeout” error).
  • Added: Option policyFile, custom location for the cross-domain policy.
  • Added: Events beforeStart/Stop/Remove for more control over the upload process (e.g. setting data from inputs).
  • Changed: 1s delay for onFail, prevents failing on slow connections.
  • Fixed: data is not correctly merged between uploader options and file-specific options.
  • Fixed: Removed debugging behaviour on progress bars.
3.0 rc1 (2009-05-05)
  • Added: New showcase attach-a-file including first iteration of the class Attach.
  • Added: New event reposition, fired when the box is moved.
  • Changed: More converted placeholder-units for validation errors.
  • Fixed: remove event did not fire correctly, broke option fileListMax
  • Fixed: Example script.php did not clear log file correctly.
  • Fixed: I really missed a console.log in FancyUpload2.js, sorry!
3.0 rc0 (2009-04-30)
  • Added: Total rewrite of Swiff.Uploader JavaScript and Actionscript
  • Added: Event based interactions from Flash to JS
  • Added: File-based list handling for easy implementation
  • Added: IFrame fallback class Uploader.js, mirroring the Swiff.Uploader API
  • Added: Several new options like appendCookieData, buttonImage and various validations
  • Fixed: All known bugs (case-sensitive typeFilter, sending data, Mac problems, load events, …)
2.0 (2008-12-05)
  • Added: Flash 10 support
  • Added: removeFile now returns the new global progress status, to refresh numbers
  • Fixed: Clickable overlay for Flash 10, define your target element with option “target”
  • Fixed: Encoding problems fixed, JS calls failed due to ExternalInterface bugs (Kudos to SwfUpload for their short and efficient fix)
  • Fixed: Cancelling a running file starts the next file
  • Fixed: Enabled cross domain upload
2.0 beta 4 (2008-05-09)
  • Fixed: Fixed fileUpload to return changed options, fixes overriding options.
2.0 beta 3 (2008-05-06)
  • Added: Optional events for every callback (e.g. onSelect, onComplete, etc.) are added automatically for more control
  • Added: Option limitSize (default false) to limit file size (in bytes) of a single selected file
  • Added: Option limitFiles (default true) to limit queue length, ignores finished files
  • Added: Option allowDuplicates (default false) to disable duplicate files in queue (checking name and size)
  • Added: Option validateFile as custom callback validator (default returns always true). Should return true or false.
  • Added: Optional callbacks for handling the file updates, allowing to control the behaviour and layout of the file elements:
    • fileInvalid: called for invalid files with error stack as 2nd argument
    • fileCreate: creates file element after select (see FancyUpload2::fileCreate for default method)
    • fileUpload: called when file is opened for upload, allows to modify the upload options (data, url, method, fieldName) for every upload.
    • fileComplete: updates the file element to completed state and gets the response (2nd argument) (see FancyUpload2::fileComplete for default method)
    • fileRemove: removes the element (see FancyUpload2::fileRemove for default method)
  • Fixed: callback options are added as events , so they don’t break FancyUpload callbacks
2.0 preview 2 (2008-04-24)
  • Fixed: Removed overflow auto from the lists to fix scrollbars.
  • Fixed: Fixed overall progress file size for removed files.
  • Fixed: New time left calculation, still needs some tweaks for the internal AS3 calculation.
2.0 preview (2008-04-21)

Refactored JS and ActionScript, it is not compatible with previous FancyUpload but a lot better!

  • Added: New Interface using all the new features (will change in the future for easier customization)
  • Added: Get the server response for uploaded files in onComplete, no longer error-catching with header status codes
  • Added: Get the current states of uploads like time left, bytes upload, for the current file and per queue … for supreme progress bars
  • Added: Set POST and GET data for the upload request
  • Added: Set the file-name for the upload request, default Filedata, like before.
  • Added: Set request options for every file, modify upload options with onBeforeOpen
  • Added: New events: onAllSelect, onBeforeOpen and onAllComplete
  • Changed: Update to MooTools 1.2 trunk and the modified Swiff Class
  • Changed: Updated to Flash 9 + ActionScript 3 for a stable API with more features
  • Fixed: Cache bug for IE, thanks to Flash 9
  • Fixed: Scroll into view bug for Firefox, fixed wmode
  • Fixed: Flash 9 works fine on Linux/Firefox
1.0.2 (2008-04-20)
  • Fixed: Fixed IE errors when unloading the page by removing the element in Swiff.Base.js
  • Fixed: Scroll into view bug for Firefox, fixed wmode
1.0.1 (2007-07-04)
  • Added: Events onError and onCancel for files
  • Change: Added better behaviour for onComplete and onAllComplete, now you can trust them
  • Change: Removed internal empty onCancel, since Flash makes it useless and some other clean-ups
  • Fixed: limitFiles works now and allowDuplicates is default true
  • Fixed: Swiff.Uploader.js: Added anti-cache fix for IE and small improvements for parameters
  • Fixed: FancyUpload.js: Fixed options in FancyUpload to work with MooTools 1.2dev
1.0 (2007-05-31)
  • Changed: Added more checks to make SWF-JS communication more stable
  • Changed: Swiff.Uploader options, swf is now the url to the swf and url the upload url
  • Fixed: Fixed a bug with multiple uploaders on one page, they all work with one injected swf
1.0 pre (2007-05-23)
  • Initial official Release

License

All files are © 2008-2009 by Harald Kirschner and available under the MIT License.

Contact & Discussion

For asking questions, requesting features, filing bugs or contributing other thoughts on this project use the support forum below. Before posting a new question, read through the documentation and the contributed notes for an answer. For problem reports make sure to add enough details like browser, version and a link or the relevant code.

You can contact me for non-support related notes.

Professional Support

I am available for hire if you look for professional and swift help. I can come to your rescue for installation, customization or extending the existing source for your needs.

Share it: Stumble it!Digg This!del.icio.us (2121 Posts: )

discussion by DISQUS 1231 Comments

Please use the support forums for discussing the project, asking questions or posting bug-fixes!

Sort:
Comments 21 – 40 of 1231:
  • reply
    Avatar
    nameless coward
    replied 1 year ago (1 Point)
    Even coders need examples to assess how well it works. When I am evaluating a lot of code samples, I'm more likely to pass on the one without examples.

    Saying that, this one has an example so I have no idea what "x" is talking about.
  • reply
    Avatar
    digitarald Site Owner
    replied 1 year ago (1 Point)
    Every showcase has docs for all assets like JS, CSS and XHTML. There even is
    a package with all files. Of course, a basic understanding of MooTools and
    its class-handling makes it easier to dive into the code.
  • reply
    Avatar
    rori 1 Point
    said 1 year ago (1 Point)
    Hi, i got some problem running it on IE6. Selecting files, OK.But when i press upload, i got only timeout.

    I try the example here with the IE6 and i got the same problem.

    Is someone make it work on IE6.
    I'm on a deadline here.. pls help ..

    rori088@gmail.com
    Thanks ..
  • reply
    Avatar
    mayid 1 Point
    said 1 year ago (1 Point)
    Oh! I solved it! I was having problems with "Upload File" button on IE8 (but not in Opera), and i almost get mad trying to understand what was going wrong.

    It was just a tag i added some days ago in the section.

    Of course! Flash didn´t managed that because of a hierarchy issue.

    Thanks a lot for this uploader! It´s great.
  • reply
    Avatar
    lnico 1 Point
    said 1 year ago (1 Point)
    this script would have been perfect with the integrated redimensioning of images
  • reply
    Avatar
    Flyerdrucken 1 Point
    said 1 year ago (1 Point)
    It´s a very fine blog. Great work! Greatings from Germany
  • reply
    Avatar
    said 1 year ago (1 Point)
    Nice uploader, but what happens is that the files upload in random order. I need a solid multiple image uploader that will keep numbers in proper sequence, or chron order by date. Got a fix for that?????
  • reply
    Avatar
    mayid 1 Point
    replied 1 year ago (1 Point)
    I think you need to sort() the files in php, so the images will display in alphabetic order instead of being ordered by 'date'.

    Try. Anyway, my pictures are naturally in alphabetic order.
  • reply
    Avatar
    ledtvprices 1 Point
    said 1 year ago (1 Point)
    Gorgeous uploader - amazed your giving it away for free!

    Thanks for sharing!
  • reply
    Avatar
    dsfsdfdsf 1 Point
    said 1 year ago (1 Point)
    asdadad
  • reply
    Avatar
    newcar
    said 1 year ago (1 Point)
    Very nice work! Congratz!
  • reply
    Avatar
    said 1 year ago (1 Point)
    Browse files is crappy.

    Minor changes to css and / or html structure and its not working anymore
  • reply
    Avatar
    mayid 1 Point
    replied 1 year ago (1 Point)
    That's exactly what is happening to me!

    How can we solve it?
  • reply
    Avatar
    said 1 year ago (1 Point)
    Very good script... Its a shame that so many halfbrained and clueless "developers" (and i use that term loosely) have to pollute your comments with there completely useless drivel. I do have one small complaint though about this example (I have to bring it up since its the primary reason Flash/JS have gotten such a bad rap all these years)... why wasn't the single file example designed to degrade properly? Sorry for posting this here... didn't seem appropriate to start a forum topic for something so minor though in what is otherwise a very clear, well commented example (To all the morons clambering above me, if you had even the slightest idea what you were doing you would understand just how simple this really is to implement with examples such as these at your fingertips)
  • reply
    Avatar
    Druckerei 1 Point
    said 1 year ago (1 Point)
    I don't know this kind of notation
    background-position: +50% 0;
    Is it possible, to notate an additional plus?

    Thx for your post Harald!
  • reply
    Avatar
    uilloc 1 Point
    said 1 year ago (1 Point)
    Hi but harald is alive?
  • reply
    Avatar
    uilloc 1 Point
    said 1 year ago (1 Point)
    hhh
  • reply
    Avatar
    Alex
    said 1 year ago (1 Point)
    Why remove button on the filelist when it is already uploaded. It status should be uploaded and disabled. Having remove button is ambigous as it certainly not remove from server.

    Anyway to change status or remove that button
  • reply
    Avatar
    said 1 year ago (1 Point)
    How I can add some data to to request? FOr example - user selects folder to store file - how I can add this to the file and workout it in script.php?
  • reply
    Avatar
    mayid 1 Point
    replied 1 year ago (1 Point)
    I did this:

    up.options.url = library/script.php?dir=some

    You can dinamically change the destination folder by altering the url option of the object.

    Then you should edit the script.php in the moving uploaded file section:
    if (isset($_GET['subdir'])) {
    $subdirectorio = $_GET['subdirectorio'];

    move_uploaded_file($_FILES['Filedata']['tmp_name'], $subdir . $_FILES['Filedata']['name']);
    $return['src'] = $subdir . $_FILES['Filedata']['name'];
Comments 21 – 40 of 1231:

Post your comment

Please use the support forums for discussing the project, asking questions or posting bug-fixes!


Internet Consultant & Contractor

I'm available to combine forces with you and your team to find the most simple, elegant and convenient web solutions . I await your call.

If you just like my work and want to say Thank You, donate via PayPal or Amazon Wish List.

Developer Resources & Tools