SwfUpload and Flash 10

SwfUpload is a graceful combination of flash and javascript that provides a mechanism for uploading files which is far more user-friendly than standard <input type=”file” />. It allows to upload many files at once and displays nice-looking progress bar.
Not everything works fine in every environment, though. Some problems are caused by the differences between some versions of flash player or even by bugs in flash players. Many of them can be solved, I wrote a post about it some time ago. But now when the Flash 10 came out, we have new obstacles to overcome.
Flash 10 is more restrictive about security issues that it’s predecessors. Now you cannot trigger opening file-select window from outside of the flash and it affects SwfUpload which used to do it from Javascript.
Thankfully, developers reacted quickly and are now working on new version (2.2) of the library. Alpha version is already out there and it deals with the mentioned problem. Since it is only alpha I recommend upgrading to stable version as soon as it comes out.
Here are inctructions how to reconfigure your app to work with SwfUpload 2.2.
First, download the most recent version of the library from SVN repository:
svn co http://swfupload.googlecode.com/svn/swfupload/trunk/core swfupload
You’ll only need two files from this: swfupload/swfupload.js and swfupload/Flash/swfupload.swf. These are the new version of files you should already have in your application. Replace old ones with these.
The new SwfUpload creates “Select files” button on it’s own, you only need to provide a placeholder for it.
<div id="swfuploadButtonPlaceHolder"></div>
The last thing is to update some Javascript.
swfu = new SWFUpload({ ... button_placeholder_id: "swfuploadButtonPlaceHolder", button_image_url: "../images/swfupload/button.jpg", button_width: "216", button_height: "25" ...});
“button_image_url” accepts a path relative to the swf file. The image it points to, should look somewhat like this:

One image containing three states of a button (normal, on mouse over, on mouse click). You can have text instead of image if you want:
swfu = new SWFUpload({ ... button_text: '<span class="theFont">Upload</span>', button_text_style: ".theFont { font-size: 16; }" ...});
That’s it. You can see working example I based on here.
If you find it useful, please share.
Related posts
4 Responses to 'SwfUpload and Flash 10'
Sorry, comments are closed for this post.

Thanks! Very helpful.
Garret Riddle
31 Oct 08 at 21:33
Thank! it works very well!! Keep rocking :-)
Ravindra
16 Jan 09 at 09:31
I meet this trouble about SwfUpload and Flash 10,and get the last version from “http://swfupload.googlecode.com/svn/swfupload/trunk/core” yesterday, but is unsuccessful also.
environment:
window 2003 sp2 IE6sp2 + Flash:10.0.12.36 FireFox3.06(Chrome2.0.157)+Flash:10.0 r12
Your advice is welcome. Thanks!
shenzhanlei
20 Feb 09 at 06:17
Sorry, I didn’t have the occasion to use the latest SWFUpload, so I can’t give any advice on this.
Michał Szajbe
19 Mar 09 at 00:53