Forum Moderators: open
I have a Flex application that exports an image as base64 encoded data(a png), and I want to save it via javascript(as far as I'm aware, there is NO way to save from flash). So, here is the code I have working:
function saveSnapshot(output)
{
var filename = "C:\\test.png";
var fso = new ActiveXObject("Scripting.FileSystemObject");
var ts = fso.CreateTextFile(filename);
ts.Write(output);
ts.Close();
}
However, I want to avoid the notepad++ step as I want other people to be able to use it easily. I have tried javascript base64 decoders(webtoolkits, for example), but it is dreadfully slow(15+mins) and it didn't even work. I found the "ScriptUtils.ByteArray" activex object, which seems great, since I can just give it a base64 string, and it even has a saveas function to directly save to a file location. However, the activex object doesn't seem to work in IE7(can't test with Ie6 yet).
var bytearray = new ActiveXObject("ScriptUtils.ByteArray");
bytearray.Base64 = output;
bytearray.SaveAs(filename);
Does anyone have any suggestions? Either an effiecent way to decode base64 in javascript, or a way to get ScriptUtils.ByteArray to work would be great.
Thanks in advance.
i tried this exact method of saving to a file (from an svg document), it seemed to work fine as when i clicked on my "save button" the browser prompted me to allow the activex script run, which i did.
it reported that data had been saved to the file successfuly with no errors, but nothing was actully saved to the file when i checked!
am i doing somethign wrong? any help on this?
cheers