文件上传transferTo路径问题

文件上传transferTo路径问题

2023年7月3日发(作者:)

⽂件上传transferTo路径问题erTo(desc);⽂件找不到路径将⽬的⽂件地址 File desc = new File(uploadDir + tor + fileName);改为 File desc = new File(new File(uploadDir).getAbsolutePath() + tor + fileName);private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException { File desc = new File(new File(uploadDir).getAbsolutePath() + tor + fileName); if (!()) { if (!entFile().exists()) { entFile().mkdirs(); } } return desc; }public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, InvalidExtensionException { int fileNamelength = ginalFilename().length(); if (fileNamelength > T_FILE_NAME_LENGTH) { throw new FileNameLengthLimitExceededException(T_FILE_NAME_LENGTH); } assertAllowed(file, allowedExtension); String fileName = extractFilename(file); File desc = getAbsoluteFile(baseDir, fileName); erTo(desc); String pathFileName = getPathFileName(baseDir, fileName); return pathFileName; }

发布者:admin,转转请注明出处:http://www.yc00.com/news/1688383012a129747.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信