1.application.properties
#Upload file size limit spring.servlet.multipart.max-file-size = 500MB spring.servlet.multipart.max-request-size = 500MB
2. Front end
// upload uploadServer: function (){ todata.append("FFILE", fhFile); todata.append("PARENT_ID", this.PARENT_ID); todata.append("NAME", this.pd.NAME); todata.append("REMARKS", this.pd.REMARKS); todata.append ("SHARE", this.SHARE); // Send post request to submit and save $.ajax({ xhrFields: { withCredentials: true }, url: httpurl+'mfolder/upload', type: 'POST', data: todata, async: false, cache: false, contentType: false, processData: false, success: function(data){ if("success" == data.result){ $ ("# fok"). tips ({side: 2, msg: 'Upload successful', bg: '# AE81FF', time: 2 }); setTimeout(function(){ top.Dialog.close (); // Close the popup window },1000); }else if("error" == data.result){ alert ("Upload failed, file content cannot be empty!"); $("#showform").show(); $("#jiazai").hide(); }else if ("exception" == data.result){ alert ("File Management" + data.exception); // Display exception $("#showform").show(); $("#jiazai").hide(); } } }) },
3. Backstage
/ ** Upload file www.1b23.com * @param * @throws Exception */ @RequestMapping(value="/upload") @RequiresPermissions("mfolder:add") @ResponseBody public Object add( @RequestParam(value="FFILE",required=false) MultipartFile file, @RequestParam(value="NAME",required=false) String NAME, @RequestParam(value="PARENT_ID",required=false) String PARENT_ID, @RequestParam(value="REMARKS",required=false) String REMARKS, @RequestParam(value="SHARE",required=false) String SHARE ) throws Exception{ Map<String,Object> map = new HashMap<String,Object>(); String errInfo = "success"; PageData pd = new PageData(); String ffile = DateUtil.getDays(), fileName = ""; if (null != file && !file.isEmpty()) { String filePath = PathUtil.getProjectpath() + Const.FILEPATHFILE + ffile; //文件上传路径 fileName = FileUpload.fileUp(file, filePath, this.get32UUID()); //执行上传 pd.put("FILEPATH", Const.FILEPATHFILE + ffile + "/" + fileName); //文件路径 pd.put("NAME", NAME); //文件名 pd.put("PARENT_ID", PARENT_ID); //目录ID pd.put("CTIME", DateUtil.date2Str(new Date())); //创建时间 pd.put("UNAME", Jurisdiction.getName()); //上传者,当前用户的姓名 pd.put("MASTER", Jurisdiction.getUsername()); //用户名 pd.put("FILESIZE", FileUtil.getFilesize(filePath + "/" + fileName)); //文件大小 pd.put("REMARKS", REMARKS); //备注 pd.put("SHARE", SHARE); //是否共享 pd.put("MFOLDER_ID", this.get32UUID()); //主键 mfolderService.save(pd); //存入数据库表 }else{ errInfo = "error"; } map.put("result", errInfo); //返回结果 return map; }