SWFUpload with flash 10

Flash player version 10 has new security restrictions with it’s javascript interaction.  It is no longer possible to trigger the local file picker from a javascript event.  Basically breaking the most legitimate use of flash in websites that I’ve seen in a while.

I use SWFUpload in a few sites to get multiple file uploads and upload progess bars.  It’s pretty slick.

The SWFUpload project has a beta release out that can work with Flash 10.  Here’s the basic changes required in your code to work with the 2.2.0 betas:

Right above your html that contains a button to trigger the file picker:

You will want to give your button a fixed width and height.

Add the following CSS rules:

.swfupload {
    position: absolute;
    z-index: 1;

And finally, add the following options to your SWFUpload settings object:

     button_placeholder_id : "spanButtonPlaceholder",
    button_width: 100,
    button_height: 40,
    button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
    button_cursor: SWFUpload.CURSOR.HAND,

This adds a transparent flash object over your html button that is the same size. Flash traps the click over your button and triggers the file picker from flash itself. Ironically, this work around for the tighter security restrictions in Flash 10 seems like a compete security risk in inself…

Pat wrote about fixing the flash 10 issue with the YUI libraries.

Comments are closed.