Here is my code that uploads a file with the path in a folder named Books , i want only the path to be stored in the database, and then fetch the files from the Books folder based on the path. Can someone guide me on how to go about.. below is my code and i am using asp.net mvc 4 and entity framework.
[HttpPost]
public ActionResult upload(HttpPostedFileBase file)
{
//verify that the file is selected and not empty
if (file != null && file.ContentLength > 0)
{
//getting the name of the file
var fileName = Path.GetFileName(file.FileName);
//store file in the Books folder
var path = Path.Combine(Server.MapPath("~/BOOKS"), fileName);
file.SaveAs(path);
}
return View();
}