| | |
| | | // } |
| | | // } |
| | | |
| | | public static void saveFile(MultipartFile file, String savePath) throws IOException { |
| | | // 创建保存文件的目录(如果不存在) |
| | | File directory = new File(savePath); |
| | | if (!directory.exists()) { |
| | | directory.mkdirs(); |
| | | } |
| | | |
| | | // 保存文件 |
| | | String fileName = file.getOriginalFilename(); |
| | | String filePath = savePath + fileName; |
| | | File dest = new File(filePath); |
| | | file.transferTo(dest); |
| | | } |
| | | // public static void saveFile(MultipartFile file, String savePath) throws IOException { |
| | | // // 创建保存文件的目录(如果不存在) |
| | | // File directory = new File(savePath); |
| | | // if (!directory.exists()) { |
| | | // directory.mkdirs(); |
| | | // } |
| | | // |
| | | // // 保存文件 |
| | | // String fileName = file.getOriginalFilename(); |
| | | // String filePath = savePath + fileName; |
| | | // File dest = new File(filePath); |
| | | // file.transferTo(dest); |
| | | // } |
| | | |
| | | public static void deleteFilesInDirectory(String directoryPath) { |
| | | File directory = new File(directoryPath); |