Я добавил поле входного файла, но оно всегда равно нулю на контроллере. Чего мне не хватает?
Вот код как для моего вида, так и для контроллера.
вид:
...
@using (Html.BeginForm())
{
...
<input type=file name="file" id="file" class="post-attachment" />
...
}
Контроллер:
[HttpPost]
public ViewResult _Details(HttpPostedFileBase file, ViewTopic viewTopic, string SearchField, string submitBtn)
{
// save file to server
if (file != null && file.ContentLength > 0)
{
var fileName = DateTime.Today.ToString("yy.MM.dd") + Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/Attachments"), fileName);
file.SaveAs(path);
}
...
}