10/30/2009 2:14:32 AM
Title:
Error when writing binary file
Hi...
I'm writing a jpg file to my flash media server and i got this error, File operation write failed.
Here is my code.. server side actionscript..
this.picFile = new File(picName + ".jpg");
this.picFile.open("binary","write");
this.picFile.write(picData);
this.picFile.close();
picData is actually a ByteArray.
Is this the correct way to write a binary file?
10/30/2009 7:01:41 AM
try using this to confirm file write permissions, it should give you a 0 byte jpg file in main.asc folder .
var picFile = new File("a.jpg");
picFile.open("binary","write");
picFile.write("ggggg");
picFile.close();
10/30/2009 8:12:37 AM
I had the same problem , had no success in writing bytearray in binary mode using fms . Then I switched to php page . I sent bytearray to php page and the file writing was handled by pahp page .
10/30/2009 9:06:53 AM
if file is coming out to be of 0 byte then probably you "picData" bytearray is not valid
binary data.
11/1/2009 8:22:49 PM
Hi Retilo
I think there shouldnt be a problem with the writing permissions.. i got a jpg file in my server when i tried your method.
Hi JFlash..
If bytearray is not valid to write binary data.. then may i know what are the datatypes that are valid to write binary data..
thks everyone....
11/2/2009 5:37:36 AM
hi, khze86
i tried to find out why its not writing jpeg data . My test application Results showed me that byte array when passed to fms is received as normal object rather than bytearray. There is no bytearray data type available on server side ActionScript 1.0. So in order to write data we need to first convert it to bytearray which seems impossible to me. Same problem occurs when we try sending data using Remote shared objects (FSO). Anyway i will keep an eye on the problem , will let you know if i found something
11/3/2009 2:10:55 AM
So is there another way to write a jpg file to the server?
11/3/2009 2:11:54 AM
So is there another way to write a jpg file to the server?
11/4/2009 12:38:46 AM
hi, khze86
I smashed my head with FMS trying to write bytearray on FMS, tried using many ways
set default encoding of bytearray to AMF0, tried reading it like array, used writeByte method , text mode, binary mode etc. All failed . I think Old ActionScript 1.0 in FMS is unable to understand the byteArray which is available in player 9 and Actionscript 3.0. You may have to use some serverside script like php, asp etc.
11/4/2009 1:44:53 AM
thanks alot jflash...
i think actionscript 1.0 is too limited.. so i'll be using php to do it..