我正在编写此代码以将文件上传到服务器用户闪存,它将文件发送到服务器,但没有显示任何进度,
var _var1:String= '';
var globalParam = LoaderInfo(this.root.loaderInfo).parameters;
for (var element:String in globalParam) {
if (element == 'host'){
_var1 = globalParam[element];
}
}
if(_var1 != '')
{
var req:URLRequest = new URLRequest(_var1);
req.contentType = 'application/octet-stream';
req.method = URLRequestMethod.POST;
req.data = recorder.output;
var loader:URLLoader = new URLLoader(req);
// set progress
loader.addEventListener(ProgressEvent.PROGRESS , fileUploadProgress);
// set on complete
loader.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA , fileUploadComplete);
// set on error handler
loader.addEventListener(IOErrorEvent.IO_ERROR , fileUploadIOError);
// set on security error handler
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR , fileUploadSecurityHandler);
// set on open
loader.addEventListener(Event.OPEN , fileUploadOpenHandler);
//ExternalInterface.call("$.jRecorder.callback_upload_progress_change" , String(0));
function fileUploadProgress(event:ProgressEvent):void{
var bytesTotal:uint = event.bytesTotal;
var bytesLoaded:uint = event.bytesLoaded;
var pctDone:Number = (bytesLoaded / bytesTotal) * 100;
ExternalInterface.call("$.jRecorder.callback_upload_progress_change" , String(pctDone));
//trace(bytesLoaded+ " / "+bytesTotal);
}
// On open
function fileUploadOpenHandler(event:Event):void{
ExternalInterface.call("$.jRecorder.callback_upload_started");
}
function fileUploadComplete(event:DataEvent):void{
ExternalInterface.call("$.jRecorder.callback_upload_finished" , String(event.currentTarget.size));;
}
function fileUploadSecurityHandler(event:SecurityErrorEvent):void{
ExternalInterface.call("$.jRecorder.callback_upload_securityproblem" , String(event.text));;
}
function fileUploadIOError(event:IOErrorEvent):void{
ExternalInterface.call("$.jRecorder.callback_upload_ioproblem" , String(event.text));;
}
}
当文件开始上传时,fileOpenHandler 到达,结束后,我得到“无限”,我无法获得任何进展或完成,我的代码哪里有问题?