I want to upload a file in folder image.
I use ASP.NET with MVC4 and razor.
I have this in my View :
<div class="editor-label"> @Html.Label("Descriptif") </div> <div class="editor-field"> <input type="file" name="fDescriptif" /> @Html.ValidationMessageFor(model => model.fDescriptif) </div> [...] <p> <input type="submit" value="Create" /> </p> In my controller :
[HttpPost] public ActionResult Create(formation formation) { if (ModelState.IsValid) { db.formations.Add(formation); db.SaveChanges(); return RedirectToAction("Index"); } return View(formation); } In my model :
public string fDescriptif { get; set; } I have no idea what I must do to upload my file in my folder "image" and save just the name of my file in my database. When I validate my form it's my complete path who saved.