I have an MVC application and this is what I intend to do. I have a field that is supposed to store the path to the file that I upload onto the server. This is the model:
int ID
string Title
string Path
And here is my controller:
public ActionResult Create(Book book)
{
if (ModelState.IsValid)
{
db.Books.Add(book);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.CreatedBy = new SelectList(db.Users, "ID", "UserName", book.CreatedBy);
return View(book);
}
I cant find a control to upload files in MVC 3. I dont know if there is a workaround since all solutions available treat the file as a separate entity on its own.
Any sample code will be appreciated.