使用commons-fileupload组件文件上传到共享服务器时报错找不到路径
大佬指点后发现是少了转义符\\
依赖
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
上传代码
public static String FileUp(MultipartFile photo) throws IOException {
String fileName = photo.getOriginalFilename();
String suffixName = fileName.substring(fileName.lastIndexOf("."));
fileName = UUID.randomUUID().toString() + suffixName;
String filePath = "\\\\192.168.200.13\\FileUpload";
File file = new File(filePath);
if(!file.exists()){
file.mkdir();
}
String finalPath = filePath + File.separator + fileName;
photo.transferTo(new File(finalPath));
return "success";
}
