使用FLEX进行多文件上传和自定义上传信息
2009-01-19 11:55:04 来源:WEB开发网窗体有两个主要方法:
通过FileReferenceList把选择的文件添加到窗体列中
publicfunctionAddItem(files:FileReferenceList,folderid:int):void{
varitem:UploadFile;
var fr:FileReference;
for(vari:uint=0;i<files.fileList.length;i++){
fr=FileReference(files.fileList[i]);
if(fr.size>SysConfig.ImageMaxSize)
{
HFSoftCoreFun.AlertError(fr.name+"文件大于"+(SysConfig.ResourceFileMaxSize/1024)+"(KB)");
break;
}
item=newUploadFile();
item.FileRef=fr;
item.FolderID=folderid;
item.Title=fr.name;
item.Name=fr.name;
item.Size=fr.size;
mUploadFiles.push(item);
}
rp.executeBindings(true);
}
对列表文件进行上传,更新窗体内容。
publicfunctionUpload_File():void{
varitem:UploadFile =UploadFile(mUploadFiles[0]);
varrequest:URLRequest=Untity.GetUploadFileRequest();
varvariables:URLVariables=new URLVariables();
variables.Title=item.Title;
variables.FolderID=item.FolderID;
request.data=variables;
item.Upload(request,function(){
DeleteUploadItem(0);
if(mUploadFiles.length>0)
intervalId=flash.utils.setInterval(function(){
flash.utils.clearInterval(intervalId);
Upload_File();
},500,null);
},function(){
rp.executeBindings(true);
});
}
更多精彩
赞助商链接