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

2

6

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?

Doubletalk answered 1/2, 2012 at 19:6 Comment(4)
Do you have an example running on a server? There's nothing that I know of that restricts FileReference.save when executing from a server, so a running example would be helpful.Halloo
It works when I run it on a localhost server but not on my online serverDoubletalk
What is fileToSave? Do onFileSave, onCancel or onSaveError trace anythingNorthward
@Northward I debugged it more and it looks like its actually a crossdomain flash security issue related to getting an image from S3 to create a bitmap out of. I've created a new question at #9218473Doubletalk
C
1

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

Carboniferous answered 26/12, 2012 at 19:43 Comment(0)
R
0

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);
}
Raimundo answered 2/3, 2012 at 16:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.