使用getFile(String parameterName, String uploadPath, Integer maxPostSize, String encoding)
上传文件时,如果uploadPath设置为Windows绝对路径,如 D:\project\test\upload\20170101,会出现上传失败,
MultipartRequest中getFinalPath未对Windows路径做处理,会出现项目路径重复路径拼接
错误信息:java.lang.RuntimeException: Directory D:\project\test\upload\D:\project\test\upload\20170101 not exists and can not create directory.
Update:
@Jfinal,上传基础地址为默认,没有在config重新设置,上传代码如下:
StringBuilder uploadPath = new StringBuilder(); uploadPath = uploadPath.append(DateKit.dateToStr(new Date(), "yyyyMMdd")).append(File.separator); UploadFile photo = getFile("file", uploadPath.toString(), 200 * 1024 * 1024, "UTF-8");
Update 2017-03-13:
今天又出现了个怪问题,上传路径无法指定,无论我在getFile中传入什么都无法修改上传路径,代码如下:
配置文件
public void configConstant(Constants me) { // 加载少量必要配置,随后可用PropKit.get(...)获取值 PropKit.use("jfinal.properties"); me.setDevMode(PropKit.getBoolean("devMode", false)); me.setBaseUploadPath(PathKit.getWebRootPath() + File.separator + "upload" + File.separator); }
上传代码:
StringBuilder uploadPath = new StringBuilder(); uploadPath = uploadPath.append(DateKit.dateToStr(new Date(), "yyyyMMdd")).append(File.separator); UploadFile photo = getFile("file", uploadPath.toString(), 20 * 1024 * 1024, "UTF-8");
用的是Jfinal3.0
@Jfinal,求助
项目:JFinal