Thanks Matt,
I had tried not setting the contentType (it's only in the code below
as I grasped at straws to get things working). But the data still
comes across without key/value pairs. The data is there server-side
but appears to be unformatted (raw, as you say).
I guess my question is - can ByteArray data only be posted as a Raw
POST? Seems odd as that would essentially exclude binary posts to
regular PHP / ASP / RoR server-side scripts with URLRequest? If I
have to write a custom handler (or Base64 encode the binary data and
post as a regular form post) that's fine - just want to make sure I
wasn't missing the obvious.
B.
--- In [EMAIL PROTECTED]ups.com,
"Matt Chotin" <[EMAIL PROTECTED]> wrote:
>
> Try not setting the contentType yourself and see what gets sent? It
> probably will just be raw binary data that you have to interpret on your
> own?
>
>
>
> ________________________________
>
> From: [EMAIL PROTECTED]ups.com
[mailto:[EMAIL PROTECTED]ups.com]
On
> Behalf Of bondbeer
> Sent: Tuesday, August 15, 2006 4:11 PM
> To: [EMAIL PROTECTED]ups.com
> Subject: [flexcoders] Posting ByteArray with URLRequest...
>
>
>
>
> Hi Guys,
>
> I've seen this question posted previously with no answer given. In
> the AS3 docs, it outlines that you can submit ByteArray data to a
> server-side script by setting the URLRequest.data property to the
> array. The problem is the docs don't seem to indicate how that data
> is sent server-side - i.e. what's the key/value pair used?
>
> My server-side code gets triggered, but the data sent doesn't look
> like a regular multipart form data that you would receive from a File
> upload. I can't parse the data.
>
> Here's what I'm doing (the dataToPost ByteArray will contain Bitmap
> data):
>
> public function postData(dataToPost:ByteArray):void
> {
> // Create a loader and init it's events
> var loader:URLLoader = new URLLoader();
> configureListeners(loader);
>
> // Create a Request object
> var url:String = "http://localhost/test/upload.aspx
> <http://localhost/test/upload.aspx>
";
> var request:URLRequest = new URLRequest(url);
> request.contentType = "multipart/form-data";
> request.method = URLRequestMethod.POST;
>
> // Set the data
> request.data = "">
>
> try
> {
> // Execute the send
> loader.load(request);
> }
> catch (error:Error)
> {
> trace("Unable to load requested document.");
> }
> }
>
> Thanks for any insight!
>
> B.
>