我正在尝试使用asp.net core 2和mvc上传文件但是我有一些代码,无论我做什么都不会解析为system.web,因为我正在使用不会解决对不起,如果这是真的简单我是web.net背景下的asp.net新手。
public ActionResult FileUpload(HttpPostedFileBase file)
{
if (file != null)
{
string pic = System.IO.Path.GetFileName(file.FileName);
string path = System.IO.Path.Combine(
Server.MapPath("~/images/profile"), pic);
// file is uploaded
file.SaveAs(path);
// save the image path path to the database or you can send image
// directly to database
// in-case if you want to store byte[] ie. for DB
using (MemoryStream ms = new System.IO.MemoryStream())
{
file.InputStream.CopyTo(ms);
byte[] array = ms.GetBuffer();
}
}
// after successfully uploading redirect the user
return RedirectToAction("actionname", "controller name");
}
服务器未解析nore是httpPostedFileBase,但这些不仅仅是System.Web中的标准方法
这些是我现有的参考资料