*** el method tiene que ser Post ***
Vista
@using (Html.BeginForm("GuardarPlanilla", "Avales", FormMethod.Post, new { id = "FormGestionPlanilla", enctype = "multipart/form-data" }))
{
@Html.TextBoxFor(m => m.RutaPlanilla, new { type = "file", Class = "btn btn-success navbar-btn" })
}
Controller
[HttpPost]
public ActionResult GuardarPlanilla(AvalPlanillaVM modelo, AvalPlanillaDetalleVM modeloDet)
{
var archivo = this.HttpContext.Request.Files.Get("RutaPlanilla");
var file = (System.Web.HttpPostedFileWrapper)(archivo);
var nombreArchivo = file.FileName.Substring(file.FileName.LastIndexOf("\\") + 1);
var rutaArchivo = this.Server.MapPath("../XLS/" + nombreArchivo);
file.SaveAs(rutaArchivo);
}
No hay comentarios:
Publicar un comentario