首页 > 其他分享 >springboot实现图片、文件接收

springboot实现图片、文件接收

时间:2022-11-05 14:11:32浏览次数:43  
标签:String File fileName 图片 file new path 接收 springboot

 

 1     /**
 2      *
 3      * @param file
 4      * @return 
 5      */
 6     @PostMapping(value = "getCategoryByUserName")
 7     public String updateConfig(@RequestParam("file") MultipartFile file) throws IOException {
 8         // 图片存储路径
 9         String path = "C:\\Project\\test01\\src\\main\\resources\\static\\ArticleImage\\";
10         // 判断是否有路径
11         if (!new File(path).exists()) {
12             new File(path).mkdirs();
13         }
14         String fileName = System.currentTimeMillis() + ".jpg";
15         file.transferTo(new File(path+fileName));
16         return path+fileName;
17     }

 

标签:String,File,fileName,图片,file,new,path,接收,springboot
From: https://www.cnblogs.com/lwl80/p/16860080.html

相关文章