it's a little tricky: You can do it one of two ways:
Arthem posted this in another thread:
This was of great help to me:
http://www.quietless.com/kitchen/upload-bitmapdata-snapshot-to-server-in-as3/
You need to modify the
URLRequestWrapper to insert field
names and file names where needed.
Here's what I've done:
bytes = 'Content-Disposition:
form-data; name="' + $fieldName + '";
filename="';
It does the most formatting of headers
so the server could understand it as a
file upload.
By the way, if you have a BitmapData
you might need to encode it to JPEG or
PNG first.
And I usually use this solution:
I haven't used the imageshack API, but you may want to try using adobe's JPGEncoder class - here's a quick example that passes a username and the JPG's byte array, it's really quite simple.
private function savePicToServer(bmpData:BitmapData):void
{
var jpgEncoder:JPGEncoder = new JPGEncoder(85);
var jpgStream:ByteArray = jpgEncoder.encode(bmpData);
var loader:URLLoader = new URLLoader();
configureListeners(loader);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var request:URLRequest = new URLRequest(ModelLocator.BASE_URL + ModelLocator.UPLOAD_URL + "?user=" + ModelLocator.getInstance().username);
request.requestHeaders.push(header);
request.method = URLRequestMethod.POST;
request.data = jpgStream;
loader.load(request);
}
Note that the variables are passed as part of the query string. You can't use URLVariables, as several people have suggested, as the URLVariables would be stored in the request's data property, which we are already using to pass the byteArray.