
html:
复制代码 代码如下:
<input type="file" name="upload" hidden="hidden" id="file_upload" accept=".zip" />
js:
复制代码 代码如下:
$.ajaxFileUpload({
url:'${pageContext.request.contextPath}/滚败Manage/BR_restorePic.action', //需要链接到服务器滑纳地址
secureuri:false,
fileElementId:'file_upload', //文件选择框的id属性
dataType: 'text', //服务器返回的格式,可以是json、xml
success: function (data, status) //相当于java中try语句块的用法
{
$('#restoreDialog').html(data)
//alert(data)
},
error: function (data, status, e){ //相当于java中catch语句块的用法
$('#restoreDialog').html("上传失败,请重试")
}
})
这个方法还会出现一个问题,就大让颤是input只能使用一次的问题,input第二次的onchange将不会被执行,这应该是与浏览器的有关,解决办法就是替换这个input
像这样:
复制代码 代码如下:
$('#file_upload').replaceWith('<input type="file" name="upload" hidden="hidden" id="file_upload" accept=".zip" />')
写一个servlet或jsp来接收,在servlet或jsp处理业务逻辑,后返回处迟枣迅理结果或新的数据如jsp:
<%@ page errorPage="/码此岩者common/error/error.jsp" %>
<%@ page contentType="text/htmlcharset=GBK"%>
<%
String planeNumber = request.getParameter("planeNumber")
String planeType = com.aerolink.aocs.system.parameter.list.PlaneTypeFactory.getPlaneType(planeNumber)
response.getWriter().write(planeType)%>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)