更新时间:2023-02-14 14:55:44
I followed the link suggested by @garethb here and used the extension method as suggested. It works!
ASP.NET RC1解决方案:
要包含的命名空间
using Microsoft.AspNet.Http;
控制器动作
[HttpPost]
public IActionResult Create(TeamVM vm)
{
FormFileExtensions.SaveAs(vm.UploadedLogo, "C:\pathTofile");
return View();
}
该答案的信用转到@garethb.
Credit for this answer goes to @garethb.
ASP.NET RC2解决方案:
要包含的命名空间
using Microsoft.AspNetCore.Http;
using System.IO;
控制器动作
[HttpPost]
public IActionResult Create(TeamVM vm)
{
// Make sure the path to the file exists
vm.UploadedLogo.CopyTo(new FileStream("C:\pathTofile", FileMode.Create));
return View();
}