官网其中的例子:
var myUpload = $(element).upload({
name: 'file',
action: '',
enctype: 'multipart/form-data',
params: {},
autoSubmit: true,
onSubmit: function() {},
onComplete: function(response) {},
onSelect: function() {}
});
实际应用:
<!-- 导入jquery核心类库 -->
<script type="text/javascript"
src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
<!-- 导入jquery-ocuppload类库 -->
<script
src="${pageContext.request.contextPath }/js/jquery.ocupload-1.1.2.js"
type="text/javascript"></script>
<script>
$(function(){
$("#button-import").upload({
name: 'upload', // <input name="file" />
action: '${pageContext.request.contextPath}/importSubarea.action', // 提交请求action路径
enctype: 'multipart/form-data', // 编码格式
autoSubmit: true, // 选中文件提交表单
onComplete: function(response) {// 请求完成时 调用函数
if(response=="success"){
alert("数据导入成功!");
}
}
});
});
</<script>