Can't write local files in Flash Player 10+ online (but works when used locally)

437 Views Asked by At

I am trying to write a local file with Flash Player 10+ using the FileReference class, following the format from this blog post by Mike Chambers: http://www.mikechambers.com/blog/2008/08/20/reading-and-writing-local-files-in-flash-player-10/

Essentially the code is this:

private function onSaveButtonClick(event:MouseEvent):void{      
    fr = new FileReference();
    fr.save(fileToSave);}

It works fine locally on my machine but when used online, it doesn't bring up the save file dialogue when the save button is clicked. I assume this is some sort of permissions or security related issue?

2

There are 2 best solutions below

0
On

You should check your log for SecurityErrors. A sandbox violation is nearly always the cause when IO works locally but not online.

0
On

Your instance of FileReference might be garbage collected. Same happens with file upload.

Try to move it to instance variable:

private var fr = new FileReference();
private function onSaveButtonClick(event:MouseEvent):void{      

    fr.save(fileToSave);
}