设置项目的根路径:
设置指定文件的在Tomcat中的虚拟路径:
代码:
String fileName = MyFileUtil.getFileName(uploadFileName);
File file = new File("/Users/Shared/jpg" , fileName);//文件目录真实路径
FileUtils.copyFile(upload, file);
customer.setCust_image("jpg/"+fileName);//“jpg/3bbbfca5c08d401f8cb982ad80527e97.jpg”