Почему у вас есть 2 файла ввода? Почему у вас есть 2 формы? Не достаточно ли первой формы (если, конечно, вы добавите в нее атрибут enctype="multipart/form-data"
, поскольку вы не можете загружать файлы без него)?:
@model PictureUploader_MVC.Models.lm_pics
@{
ViewBag.Title = "Create";
}
<h2>Upload Picture</h2>
@using (Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>lmit_pics</legend>
<div class="editor-label">
@Html.LabelFor(model => model.brand)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.brand)
@Html.ValidationMessageFor(model => model.brand)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.enabled)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.enabled)
@Html.ValidationMessageFor(model => model.enabled)
</div>
<div>
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
</div>
</fieldset>
<button type="submit">Create</button>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
и действие вашего контроллера, которое будет обрабатывать отправку формы:
[HttpPost]
public ActionResult Create(lm_pics lm_pics, HttpPostedFileBase file)
{
...
}