I'm trying to upload a file through URLLoader in Actionscript 3, I know it's possible, at least according to the docs, but I can't figure it. So if anyone has done this before I'd love to know what I'm leaving out, specifically, I'm unsure about URLRequest and its data property. I know that my file's data should go there, but I'm unsure as to how.
Here's a very rudimentary form of the code I'm working with:
//===============================================
public function sendRequest():void {
//===============================================
var newFile:FileReference(); //this eventually gets data loaded to it before I make request
var sendForm:URLLoader = new URLLoader();
var urlString:String = "/proposal_request/?";
var header:URLRequestHeader = new URLRequestHeader("Content-Disposition: attache[attachment]; filename=" + newFile.name);
...
...
urlString += "variable=" + instance_name.text;
urlString += "another_variable=" + another_instance_name.text;
...
...
var requester:URLRequest = new URLRequest(urlString);
requester.contentType = "multipart/form-data";
requester.method = URLRequestMethod.POST;
requester.requestHeaders.push(header);
requester.data = newFile; //here's where I'm most confused, should this be encoded?
...
...
sendForm.addEventListener(HTTPStatusEvent.HTTP_STATUS, responseStatus);
sendForm.load(requester);
}