0
List<String> _lista = new List<String>();
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(Veiculo veiculo, HttpPostedFileBase[] file)
{
for (int i = 0; i < file.Length; i++)
{
var fileName = Guid.NewGuid().ToString() +
System.IO.Path.GetExtension(file[i].FileName);
file[i].SaveAs(HttpContext.Server.MapPath("~/Fotos/")
+ fileName);
_lista.Add(fileName);
}
veiculo.Imagem1 = _lista[0];
veiculo.Imagem2 = _lista[1];
veiculo.Imagem3 = _lista[2];
veiculo.Imagem4 = _lista[3];
veiculo.Imagem5 = _lista[4];
db.Veiculo.Add(veiculo);
db.SaveChanges();
return RedirectToAction("Index");
}
What I need is that the user can upload as many images as he wants and not only 5 as and done in my code.