我在HttpPostedFileBase
上收到错误:
无法找到类型或命名空间名称'HttpPostedFileBase'(您是否缺少using指令或程序集引用?)
我已尝试使用using System.Web
,但根本无法使用。
编辑#1
public IActionResult Upload(HttpPostedFileBase file)
{
if (file.contentlength > 0)
{
var filename = Path.GetFileName(file.filename);
var path = Path.Combine(Server.mappath("~/app_data/uploads"), filename);
file.saveas(path);
}
return RedirectToAction("index");
}
我实际上没有参考文件夹No references folder
答案 0 :(得分:3)
You can't mix and match tutorials and framework versions. You're on ASP.NET Core 2.0.8, which doesn't contain HttpPostedFileBase
.
The ASP.NET Core counterpart of HttpPostedFileBase
is IFormFile
.
答案 1 :(得分:0)