<script type="text/Javascript" src="<%=contextPath%>/plupload/jquery-1.7.2.min.js"></script>
<link rel="stylesheet" href="<%=contextPath%>/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css" type="text/css"/>
<script type="text/javascript" src="<%=contextPath%>/plupload/plupload.full.min.js"></script>
<script type="text/javascript" src="<%=contextPath%>/plupload/jquery.plupload.queue/jquery.plupload.queue.js"></script>
<script type="text/javascript" src="<%=contextPath%>/plupload/i18n/zh_CN.js"></script>
<body>
<div id="uploader" style="width: 500px;height: 500px;border: 1px solid;"></div>
<script type="text/javascript">
var hasError = false;
$(document).ready(function() {
$("#uploader").pluploadQueue({
runtimes : 'html5,gears,browserplus,silverlight,flash,html4',
url : "Upload",
max_file_size : "100MB",
multiple_queues : false,
unique_names : true,
rename : true,
dragdrop : true,
urlstream_upload : true,
multi_selection : false,
filters : [ {title : "Excel files", extensions : "xls"}],
flash_swf_url : "<%=contextPath%>/plupload/Moxie.swf",
silverlight_xap_url : "<%=contextPath%>/plupload/Moxie.xap",
init : {
FilesAdded:function(up,files){ //控制只能添加一个文件
$.each(up.files, function (i, file) {
if (up.files.length <= 1) {
return;
}
up.removeFile(file);
});
},
UploadComplete:function(up,files){ //上传完成
if(!hasError){
alert('处理成功')
}else {
alert('文件上传获取解析失败')
hasError = false;
}
},
Error: function(up, args) { //上传失败
hasError = true;
}
}
});
});
</script>
</body>