Related Resources Download: Upload
1:jsp Code:
Import Jquery.upload.js and Jquery-1.7.2.js
Add code to call JS: <a href= "javascript:void (0)" rel= "external nofollow" onclick= "Doupload ()" > Upload </a>
Write at the bottom:
<iframe style= "position:absolute;top:-9999px" src= "<%=basepath%>/resources/upload/upload.htm"/></ Iframe>
2:js Code:
* * File Upload/
function doupload () {//
upload Method
$.upload ({
//upload address
url:window.basepath+ '/reply/ Imageupload ',//
file domain name
filename: ' uploadfile ',//
other form data
params: {},
//After uploading, return JSON, text
dataType: ' json ',
//callback before uploading, return true to continue uploading
onsend:function () {return
true;
},
Onsubmit:function () {
},
//After uploading callback
oncomplate:function (data) {
if (data.msg) {
}else{
alert ("Upload image Error!") ");
}
}
});
}
3: Background code:
/** * Picture upload local server * @param request * @param response * @return * * @RequestMapping (value= "I Mageupload ") @ResponseBody public Object imageupload (httpservletrequest request,httpservletresponse response) {Map
<string, object> map=new hashmap<string, object> ();
Uploadutil uploadutil = new Uploadutil (); try {String url = uploadutil.excelupload (request, response);//File Upload} catch (IOException e) {e.printstacktrace ();} Retu
RN map; }