function Selectseal () {
document.getElementById ("Sealinfo"). Click ();
}
function Updateseal (Sealimageupdateid) {
var sealinfo = {};
Sealinfo.sealimageupdateid = Sealimageupdateid;
$.ajaxfileupload ({
URL: ' ${pagecontext.request.contextpath}/seal/uploadsealinfo.do ',
Secureuri:false,
Fileelementid: ' Sealinfo ',
DataType: ' JSON ',
Data:sealinfo,
Success:function (data, status) {
if (data = = "0") {
Location.reload ();
} else {
Alert ("Upload failed");
}
},
Error:function (data, status, E) {
Alert (e);
}
});
}
<input id= "Btn_sealchange" type= "button" value= "Change Seal" class= "btn btn-info" onclick= "Selectseal (${seal.sealimageid });" ><input id= "Sealinfo" name= "file" type= "file" onchange= "Updateseal (${seal.sealimageid});" style= "Display:none" >
@RequestMapping (value = "Uploadsealinfo") public @ResponseBody String Uploadsealinfo (@RequestParam (value = "File", Required = false) Multipartfile file, @RequestParam (value = "Sealimageupdateid") Long id,httpservletresponse response) { try {byte[] Sealbyte = File.getbytes (); Sealinfo sealinfo = new Sealinfo (); Sealinfo.setfiledata (sealbyte); Sealinfo.setid (ID); This.sealService.uploadSeal ( Sealinfo); return "0";} catch (IOException e) {e.printstacktrace (); return "-1";}}
Java Upload Data