function selectSeal() {
document.getElementById("sealinfo").click();
}
function updateSeal(sealp_w_picpathupdateId) {
var sealinfo = {};
sealinfo.sealp_w_picpathupdateId = sealp_w_picpathupdateId;
$.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("上传失败");
}
},
error : function(data, status, e) {
alert(e);
}
});
}
class="btn btn-info"
οnclick="selectSeal(${seal.sealImageId});">
οnchange="updateSeal(${seal.sealImageId});"
style="display: none">
@RequestMapping(value = "uploadSealInfo")
public @ResponseBody String uploadSealInfo(
@RequestParam(value = "file", required = false) MultipartFile file,
@RequestParam(value = "sealp_w_picpathupdateId") 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";
}
}
//更新mysql blob
update seal_info set file_data=#{fileData}
where id = #{id,jdbcType=BIGINT}