1、前端代码
<form id="unionpayEncSave" name="unionpayEncSave" method="post" action="${olt_url}/org/unionPay/encSave" enctype="multipart/form-data">
<table class="form_table pt15 pb15" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="td_right">上传证书:</td>
<td>
<input type="hidden" name="unionpay_wechat_merchant_no" id="unionpay_wechat_merchant_no" />
<input name="file_name" id="enc_name" class="easyui-filebox" style="height:30px" data-options="onChange:function(){$(this).val($(this).filebox('getValue'))},prompt:'敏感加密证书'" size="20" value="${enfiles.enc_name }">
<input name="file_name" id="root_name" class="easyui-filebox" style="height:30px" data-options="onChange:function(){$(this).val($(this).filebox('getValue'))},prompt:'根证书'" size="20" value="${enfiles.root_name }">
<input name="file_name" id="middle_name" class="easyui-filebox" style="height:30px" data-options="onChange:function(){$(this).val($(this).filebox('getValue'))},prompt:'中级证书'" size="20" value="${enfiles.middle_name }">
<input name="file_name" id="sign_name" class="easyui-filebox" style="height:30px" data-options="onChange:function(){$(this).val($(this).filebox('getValue'))},prompt:'商户私钥证书'" size="20" value="${enfiles.sign_name }">
<input type="submit" name="unionpayEncSaveBtn" id="unionpayEncSaveBtn" class="btn btn82 btn_save2" value="上传">
</td>
</tr>
</table>
</form>
2、后端代码
String basePath = SKOrgService.class.getClassLoader().getResource("").getPath()+"key/unionpayqrcode/"+wechatMerchantNo;
for(MultipartFile file : files){
String filePath = basePath + "/" + file.getOriginalFilename();
File desFile = new File(filePath);
if(!desFile.getParentFile().exists()){
desFile.mkdirs();
}
try {
file.transferTo(desFile);
} catch (IllegalStateException | IOException e) {
e.printStackTrace();
result.put("msg", "处理失败");
return result;
}
}