上传使用flash插件
需要jquery.uploadify.min.js,uploadify.css,poi-ooxml-3.8-20120326.jar等
jsp页面:
margin:010px;
}
//导入功能
$(function() {
$("#uploadFile").uploadify({
buttonClass :'',
fileSizeLimit :'51200KB',
uploader :'${basePath}core/upload!uploadFile.action', //服务器端处理地址
swf : '${basePath}js/uploadify/uploadify.swf', //上传使用的 Flash
buttonText : "导入",
buttonCursor :'hand',
fileObjName :'uploadify',//上传参数名称 后台action里面的属性uploadify
fileTypeExts : "*.xls;*.xlsx", //扩展名
fileTypeDesc : "请选择 文件格式",
removeTimeout :1, //文件说明
auto : true, //选择之后,自动开始上传
multi : false, //是否支持同时上传多个文件
queueSizeLimit : 1, //允许多文件上传的时候,同时上传文件的个数
queueID : 'queueID',
onUploadSuccess : function(file, data, response) {var data =jQuery.parseJSON(data);if (data.error == 1) {
ldDialog.alert(data.message);
}else{
$.ajax({
url :"${basePath}uploadDocumentAction/uploadDocument!importManyOverallPlan.action",
type :"post",
dataType :"json",
data : {
filePath : data.url,
fileName : data.newFileName,
proId :"${proId}",
},async : false,
success : function(r) {if (r.code == 'success') {
ldDialog.tips("导入成功!");
document.pagerForm.submit();
}else{
ldDialog.tips("导入失败!");
}
}
});
}
}
});
});
模板下载
uploadDeclare.jsp
//防止客户端缓存文件,造成uploadify.js不更新,而引起的“喔唷,崩溃啦”
document.write ("
width: 130px;
margin: 0px;
margin-top: 10px;
}
效果页面:
excel文件放在eclipse-workspace\report\WebRoot\upload\template\template13.xlsx目录下,都有的字段:
jsp页面 url : "${basePath}uploadDocumentAction/uploadDocum