diff --git a/_data/comments/uploading-files-with-aspnetmvc-aspx/4dffca65.yml b/_data/comments/uploading-files-with-aspnetmvc-aspx/4dffca65.yml new file mode 100644 index 000000000..efa7b822c --- /dev/null +++ b/_data/comments/uploading-files-with-aspnetmvc-aspx/4dffca65.yml @@ -0,0 +1,5 @@ +id: 4dffca65 +date: 2023-12-04T03:37:16.2165285Z +name: Andi +avatar: https://github.com/Keskebeu.png +message: "How about saving it to a database. So lets say an array instead.\r\nI am trying to use:\r\n[HttpPost]\r\n[ValidateAntiForgeryToken]\r\npublic async Task Create(Bind[\"Binding here\"]Person person)\r\n{\r\n \r\n List list = new List();\r\n if (Request.Form.Files.Count > 0)\r\n {\r\n var dataStream = new MemoryStream();\r\n for (var i = 0; i < Request.Form.Files.Count;i++)\r\n {\r\n var files = Request.Form.Files[i];\r\n await files.CopyToAsync(dataStream);\r\n person.Files[i].Name = files.FileName;\r\n person.Files[i].Data = dataStream.ToArray();\r\n }\r\n }\r\n list.Add(person);\r\n return RedirectToAction(nameof(Index));\r\n}\r\nRazor View:\r\n\r\n
\r\n \r\n \r\n \r\n \r\n \r\n for(var i = 0; i < 2; i++)\r\n{\r\n \r\n}\r\n\r\n \r\n
\r\nYou can mess with the DOM to add more rows of inputs.\r\nI was looking for a more finessed way of one input with multiple files like below\r\n\r\nWhen I do I get the error \"index out of range\".\r\nAny thoughts?\r\n\r\n"