SpringBoot上传文件
来源:互联网 发布:地图数据可视化 编辑:程序博客网 时间:2024/05/01 11:26
后台代码
private String saveFile(MultipartFile file) { try { if (file.isEmpty()) { log.info("file is empty"); return ""; } String fileName = StringUtils.cleanPath(file.getOriginalFilename()); if (fileName.contains("..")) { // This is a security check log.error("Cannot store file with relative path outside current directory {}", fileName); return ""; } log.info("ready to save {}, {}", file.getOriginalFilename(), fileName); String path = "data/upload/"; if (!Paths.get(path).toFile().exists()) { Paths.get(path).toFile().mkdirs(); } Files.copy(file.getInputStream(), Paths.get(path).resolve(fileName), StandardCopyOption.REPLACE_EXISTING); return file.getOriginalFilename(); } catch (Exception e) { log.error("saveFile Exception {}", e); } return ""; }
前台代码
uploadFile(@RequestParam("file") MultipartFile file)
https://github.com/spring-guides/gs-uploading-files
阅读全文
0 0
- SpringBoot文件上传
- springboot文件上传
- SpringBoot上传文件
- springboot 文件上传
- SpringBoot之文件上传
- springboot 文件上传
- SpringBoot实现文件上传
- springboot 上传文件
- Springboot 文件上传
- SpringBoot上传文件
- SpringBoot文件上传控制
- springboot上传文件
- springboot+文件上传和下载
- springboot实现多文件上传
- springboot 文件上传大小配置
- SpringBoot轻松实现文件上传
- 15.springboot实现文件上传
- SpringBoot文件上传和下载
- 第四章——检索数据(MYSQL必知必会)
- 树莓派-内核开发-说明 下载代码 编译 替换内核
- Maven 搭建spring boot多模块项目
- luogu P1443 马的遍历 【队列 dfs】
- ftp文件传输协议
- SpringBoot上传文件
- (转)姚期智:呼之欲出的量子计算机,和它漫长的最后一英里(全文)
- Android网络编程
- 创建继承于类person的类student并重写方法
- linux—c结构体学习
- 处理输入成绩异常
- 线程基础(二):线程锁和条件变量(笔记)
- Hibernate的查询方式
- windows中AD域的部署