ajax提交表单包括文件
<script
src="${pageContext.request.contextPath}/assets/js/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(function() {
$("#upload").click(function() {
var formData = new FormData($("#uploadForm")[0]);
$.ajax({
url : "${pageContext.request.contextPath}/uploadoldimage",
type : 'POST',
data : formData,
async : false,
cache : false,
contentType : false,
processData : false,
success : function(data) {
var obj = eval('(' + data + ')');
if (obj.status == 'success') {
alert("上传完成");
$("#posterShow").attr("src",obj.imgurl);
$("#posterShow").css("width","450px");
$("#posterShow").css("height","300px");
$("#showimg").val(obj.imgurl);
}
},
error : function() {
alert("网络异常");
}
});
})
})
</script>
支持主流浏览器
非要用IE还是另寻他法吧