上传
public UploadVo upload(MultipartFile file) throws Exception { UploadVo uploadVo = new UploadVo(); if (!file.isEmpty()) { String fileName = file.getOriginalFilename(); String fileType = fileName.substring(fileName.lastIndexOf(".")+1); long fileSize = file.getSize(); String Path = "D:\\javaspace\\tomcatPath"; File packageFile = new File(Path); if (!packageFile.exists()) { packageFile.mkdir(); } File targetFile = new File(Path + "\\" + fileName); file.transferTo(targetFile); uploadVo.setBeginFileName(fileName); uploadVo.setLastFileName(fileName); uploadVo.setFileSize(String.valueOf(fileSize)); uploadVo.setResult("上传成功"); return uploadVo; } else { uploadVo.setResult(String.valueOf(ErrorMessageConstant.ERROR_CODE_10004)); return uploadVo; } }