Skip to content

Commit

Permalink
修正上传文件时提示目录不存在的bug,确保保存文件之前先创建目录
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Dec 22, 2019
1 parent 2db8919 commit e6e06cd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NewLife.Cube/Areas/Admin/Controllers/FileController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ public ActionResult Upload(String r, IFormFile file)

var dest = di.FullName.CombinePath(file.FileName);
WriteLog("上传", dest, UserHost);

dest.EnsureDirectory(true);
System.IO.File.WriteAllBytes(dest, file.OpenReadStream().ReadBytes());
}

Expand All @@ -278,6 +280,8 @@ public ActionResult Upload(String r, HttpPostedFileBase file)

var dest = di.FullName.CombinePath(file.FileName);
WriteLog("上传", dest);

dest.EnsureDirectory(true);
file.SaveAs(dest);
}

Expand Down

0 comments on commit e6e06cd

Please sign in to comment.