0
я пытаюсь загрузить файл из формы с помощью ASP MVC 5.ASP .NET файл загрузки - HttpPostedFileBase = нуль
Но мой file.ContentLength
всегда = 0
public ActionResult Test(int? id, HttpPostedFileBase file)
{
if (file != null && file.ContentLength > 0)
{
//blabla
}
}
и здесь моя форма .cshtml
using (Html.BeginForm("Test", "MyController",FormMethod.Post, new { id = Model.Id, enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
<input type="file" id="file" name="file" />
<div class="form-group">
<button type="submit">Ajouter</button>
</div>
}
Спасибо, мой запрос есть ContentLength> 0 (Request.File [0]), butmy вар файл = Request.Files [0] имеют ContentLength = 0 – Alexis
О, это, наконец, работа, моя contentLength автоматически переходит в 0 в моей отладке, но моя вставка в DB выглядит хорошо. Спасибо ! – Alexis
Наконец-то вы получили решение, довольный этим. –