If you are using AMF3 (RemoteObject), you can serialize binary data
without any conversion. If you are trying a standard HTTP post, I would
use a HTTPService with the method= "POST". Then you have to Base64
encode the binary data and attach it to the parameters of the http
service. On the server side, you will need to decode the base64 encoded
data back into binary.
Example:
<mx:HTTPService
id="httpService"
showBusyCursor="true"
useProxy="false"
method="POST"
resultFormat="text"
url="/BinaryData/cf/HTTPImageSave.cfm"
result="onResult('Data Saved via mx:HTTPService')"
fault="onFault(event)" />
private function base64Encode( data : ByteArray ) : String
{
var encoder : Base64Encoder = new Base64Encoder();
encoder.encodeBytes( data );
return encoder.flush();
}
private function sendData() : void
{
var data : ByteArray = encoder.encode( myPngByteArray );
var params : Object = { data : base64Encode( data ) };
httpService.send( params );
}
In ColdFusion, you can decode the base64 data simply by using the
"toBinary" function. Other languages have similar functions as well.
Just a FYI... using the JPG instead of PNG requires significantly less
bandwidth & time to post the data to the server. Base64 encoding the
data also increases the size of the data being transferred "across the
wire". It is much more efficient to use a remoteObject method with
JPG-compressed data.
-Andy
_____________________________________
Andrew Trice
Cynergy Systems, Inc.
http://www.cynergysystems.com
Blog: http://www.cynergysystems.com/blogs/page/andrewtrice
Email: [EMAIL PROTECTED]
Office: 866-CYNERGY
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Simeon Bateman
Sent: Thursday, January 25, 2007 2:20 PM
To: [email protected]
Subject: Re: [flexcoders] Posting PNG to server
I have done this with ColdFusion using the RemoteObject tag. Can you
use one of the remote object php tools to pass the binary data?
simeon
On 1/25/07, franto <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> >
wrote:
Hi,
Please help me, how can I post PNG (ByteArray created by Tini Uro's
convertor) to server (PHP)
Im try URLLoader + URLRequest.data = png
but it doesnt work :(
Does anyone know, what should I do?
Thanks
P.S. Close to deadline :))
Franto