日期:2014-05-16 浏览次数:20931 次
var button = $('#upload_button'); //定义能够上传文件的按钮,就是一个普通的button
var fileType = "zip",fileNum = "one"; //定义能够上传的文件类型,当然要靠后面的onSubmit中的js去做判断
new AjaxUpload(button,{
action: '${ctp}/app/assistVerify/importShanghairReportAction.shtml',
name: 'shanghaiFile', //这相当于<input type = "file" name = "shanghaiFile"/>
onSubmit : function(file, ext){
if(fileType == "zip")
{
if (ext && /^(zip|rar)$/.test(ext)){
this.setData({
'info': '文件类型为压缩包' //这个info 暂时无效
});
} else {
alert('非压缩包类型文件,请重传');
return false;
}
}
button.text('导入上海资信中...');
if(fileNum == 'one') //同时上传的文件数不能超过一个
this.disable();
},
onComplete: function(file, response){ //上传完毕后的操作
if(response != "success")
alert(response);
button.text('导入上海资信');
this.enable();
if(response == "success");
alert("导入上海资信成功");
//有了response我们能做任何事了,返回的文件名称,文件路径等我们可以随意操作的!
}
});