调用代码 : getFile("parm", "E:/resources/", 3*1024*1024);
执行到 MultipartRequest 类中class getFinalPath方法。uploadPath 值为"E:/resources/",
if (uploadPath.startsWith("/") || uploadPath.startsWith("\\")) 进不去!
\\ 是不是应该改为: 号啊?
private String getFinalPath(String uploadPath) {
if (uploadPath == null) {
throw new IllegalArgumentException("uploadPath can not be null.");
}
uploadPath = uploadPath.trim();
if (uploadPath.startsWith("/") || uploadPath.startsWith("\\")) {
if (baseUploadPath.equals("/")) {
return uploadPath;
} else {
return baseUploadPath + uploadPath;
}
} else {
return baseUploadPath + File.separator + uploadPath;
}
}
导致无法上传!
Directory E:\upload\E:/resources/ not exists and can not create directory.
具体到方案,可以通过 me.setBaseUploadPath("E:/resources/") 配置一下就好
如果你的项目有所谓的多个 baseUploadPath 存在,可以用一下 File 移动目录来实现