I am trying to upload a file using asp.net core 2 and mvc however I have some code which No matter what I do will not resolve to system.web as I am using the that will not resolve sorry if this is really simple I am new to asp.net comming from a webforms background.
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");
}
Server is not resolved nore is httpPostedFileBase but are these not just standard methods in System.Web anymore
These are my existing references