I am trying to make a file upload program using as3 and amfphp. Instead of using the upload method I am instead calling an amfphp function and passing the filereference.data as one of the paramaters. This works well and good, however, i have no way to track the progress of the file upload, other then when it completely finishes uploading. I’ve decided to chunk up the bytearray in flash before i pass it so that i can get more progress information during the upload. The problem is when I try to take the data from filereference and put it into a bytearray it gives me an End of file was encountered error.
Here is an oversimplified version of what i’m trying to do
stage.addEventListener(MouseEvent.CLICK, clickhandler);
var fileref:FileReference = new FileReference();
fileref.addEventListener(Event.SELECT, onselect);
fileref.addEventListener(Event.COMPLETE, complete);
function clickhandler(evt:MouseEvent):void{
fileref.browse();
}
function onselect(evt:Event):void{
fileref.load();
}
function complete(evt:Event):void{
var ba:ByteArray = new ByteArray();
ba.readBytes(fileref.data,0,fileref.data.bytesAvailable);
}
Is there something simple i’m overlooking, even if the bytearray was empty, i used the bytesAvailable property in this example and it still gives me the end of file error, is it just me or is this a bug with flash?