search

Home  >  Q&A  >  body text

java - 文件上传后我希望把文件保存在我自己创建的一个文件夹中

File fileSourcePath = new File("resources/upload/");
File fileSource = new File(fileSourcePath, mulFileSource.getOriginalFilename());
if (!fileSourcePath.exists()) {
    fileSourcePath.mkdirs();
}
// 将接收得图片暂存到临时文件中
mulFileSource.transferTo(fileSource);

我想把上传的文件保存在upload文件夹中,怎么写路径。这样写会报
java.io.FileNotFoundException错误

PHPzPHPz2892 days ago305

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-04-18 09:20:09

    What the hell is the picture you uploaded?

    If you run it in eclipse, it should be a relative path with the project directory as the root, such as src/main/resources/upload/

    reply
    0
  • Cancelreply