Si j'écris comme ça:
form action = "Images" method = "post" enctype = "multipart / form-data"
Ça marche.
Mais dans Razor avec '@' cela ne fonctionne pas. Ai-je fait des erreurs?
@using (Html.BeginForm("Upload", "Upload", FormMethod.Post,
new { enctype = "multipart/form-data" }))
{
@Html.ValidationSummary(true)
<fieldset>
Select a file <input type="file" name="file" />
<input type="submit" value="Upload" />
</fieldset>
}
Ma manette ressemble à ceci:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Upload()
{
foreach (string file in Request.Files)
{
var uploadedFile = Request.Files[file];
uploadedFile.SaveAs(Server.MapPath("~/content/pics") +
Path.GetFileName(uploadedFile.FileName));
}
return RedirectToAction ("Upload");
}