0

I built a flash applet to record voice and encode it to a MP3 bytearray. By calling the upload method of a fileReference object and passing URLRequest as parameters, one can upload the file referred to a script that can process the data(e.g. php). However, FileReference.data is read-only, so I cannot figure out a way to pass the MP3 bytearray to a FileReference object, or create a file inside AS3 and load it to the FileReference object. By the way, I don't want the user to download the file and upload it manually. Is there any way to solve this problem?

DQLin
  • 17
  • 4
  • Here's your answer: http://stackoverflow.com/questions/9559948/post-file-upload-using-urlrequest Use `URLRequest` without `FileReference`. – Vesper Jul 25 '14 at 09:47
  • Thanks! I also find a external source to easily upload multipart/form-data. – DQLin Jul 25 '14 at 17:06

1 Answers1

0

FileReference is not used to analyze the loaded content, but to load files between a server and a computer. To do this, you can use URLLoader class. Listening the events is directly made by the URLLoader object.

var loader:URLLoader = new URLLoader();
loader.load(new URLRequest("myFile"));
loader.addEventListener(Event.COMPLETE, loadingFinished);

To access the data, we use data's property of the URLLoader object :

function loadingFinished(e:Event):void {
    trace(e.currentTarget.data);
}
helloflash
  • 2,457
  • 2
  • 15
  • 19