title: Multiple file upload in asp.net core is not working
body: <p>I am working on .net core 3.1. My problem is when I try to upload multiple files it is picking only the file which I have uploaded latest. For egg, when I upload 3 files only the third file is coming into the controller.</p>
  <p>My model:</p>
  <pre><code>public class ProductModel
      {
          public int ProductId { get; set; }
  
          [Required(ErrorMessage =&quot;Product Name is Required&quot;)]
          public string ProductName { get; set; }
  
          public string ProductDescription { get; set; }
  
          [Required(ErrorMessage =&quot;Atleast one category need to be selected&quot;)]
          public int[] ProductCategoryIds { get; set; }
  
          public string Category { get; set; }
  
          [Required(ErrorMessage = &quot;Product Needs to have any brand&quot;)]
          public int? BrandId { get; set; }
  
          public string BrandName { get; set; }
  
          [Required(ErrorMessage =&quot;Tax is Required&quot;)]
          public int? TaxId { get; set; }
  
          public DateTime CreatedDate { get; set; }
  
          [Required(ErrorMessage =&quot;Product Price is Required&quot;)]
          public decimal? ProductPrice { get; set; }
  
          public string ProductModels { get; set; }
  
          [Required(ErrorMessage =&quot;Available quantity is Required&quot;)]
          public  int? AvailableQuantity { get; set; }
  
          public string StockStatus { get; set; }
  
          [Required(ErrorMessage = &quot;Image is Required&quot;)]
          [ValidateFile(ErrorMessage =&quot;Invalid File Type&quot;)]
          //[RegularExpression(@&quot;([a-zA-Z0-9\s_\\.\-:])+(.png|.jpg|.JPG|.PNG)$&quot;, ErrorMessage = &quot;Invalid File types&quot;)]
          public IFormFile ProductImage { get; set; }
  
          public string ProductImagePath { get; set; }
  
          public List&lt;IFormFile&gt; AdditionalImages { get; set; }
  
          public bool IsActive { get; set; }
  
          public string ColorAttribute { get; set; }
  
          public int? DiscountProductCount1 { get; set; }
          public int? DiscountProductCount2 { get; set; }
          public int? DiscountProductCount3 { get; set; }
  
          public int[] AttributesId { get; set; }
  
          public string AttributesAsString { get; set; }
  
          public decimal? DiscountProductPrice1 { get; set; }
          public decimal? DiscountProductPrice2 { get; set; }
          public decimal? DiscountProductPrice3 { get; set; }
  
          public string DiscountJson { get; set; }
  
          public decimal? ProductPriceOffer { get; set; }
  
          public int? MinimumQuantity { get; set; }
  
          public List&lt;ProductImageModel&gt; ProductImageList { get; set; }
  
          public List&lt;CategoryModel&gt; CategoryList { get; set; }
  
          public TaxModel Tax { get; set; }
  
          public List&lt;TaxModel&gt; TaxList { get; set; }
  
          public List&lt;AttributesModel&gt; AttributesList { get; set; }
  
          public List&lt;ProductDiscountModel&gt; DiscountsList { get; set; }
  
          public string CreatedBy { get; set; }
      }
  </code></pre>
  <p>My cshtml:</p>
  <pre><code> &lt;form asp-action=&quot;NewProducts&quot; asp-controller=&quot;Product&quot; method=&quot;post&quot; autocomplete=&quot;off&quot; enctype=&quot;multipart/form-data&quot;&gt;
   &lt;div class=&quot;form-group col-md-6&quot;&gt;
                    &lt;label&gt;Product Additional Image&lt;/label&gt;
                     &lt;input type=&quot;file&quot; class=&quot;form-control&quot; id=&quot;AdditionalImages&quot; asp-for=&quot;Product.AdditionalImages&quot; multiple 
                          placeholder=&quot;Product Additional Image&quot;&gt;
                     
                  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  <p>My controller, when I submits only the latest file is coming into the  controller:</p>
  <pre><code>public IActionResult NewProducts(ProductModel product)
          {
              try
              {
                  if (ModelState.IsValid)
                  {
                      product.AttributesAsString = GetAttributesAsJson(product);
                      product.DiscountJson = GetDiscountsAsJson(product);
                      //saving general and category details of product
                      ProductModel results = _product.SaveProductGeneral(product);
                      product.ProductId = results.ProductId;
                      List&lt;ProductImageModel&gt; images= GetProductImages(product);
                      
                      //saving all images
                      //string allImagesJson = JsonConvert.SerializeObject(images);
                      foreach(var image in images)
                      {
                          _product.SaveProductImages(image);
                      }
                      
                      ViewData[&quot;SuccessFormMessage&quot;] = &quot;Created Successfully&quot;;
                      ViewData[&quot;ErrorFormMessage&quot;] = string.Empty;
                      ModelState.Clear();
                  }
                  else
                  {
                      ViewData[&quot;SuccessFormMessage&quot;] = string.Empty;
                      ViewData[&quot;ErrorFormMessage&quot;] = &quot;Check all Required Fields&quot;;
                  }
  
                  ProductViewModel container = new ProductViewModel();
                  container.Heading = new HeadingModel();
                  container.Heading.MainHeading = &quot;Product Management&quot;;
                  container.Heading.SubHeading = &quot;Addd new products for your store&quot;;
                  ViewData[&quot;BrandDropDown&quot;] = CommonUtils.CommonUtils.GetDropDownByType(_brand.GetAllBrandsByType(&quot;Active&quot;), null, &quot;brand&quot;);
                  ViewData[&quot;TaxDropDown&quot;] = CommonUtils.CommonUtils.GetDropDownByType(_tax.GetAllTaxesForDropDown(&quot;product&quot;), null, &quot;tax&quot;);
                  ViewData[&quot;CategoryDropDown&quot;] = CommonUtils.CommonUtils.GetDropDownByType(_category.GetCategoriesByStatus(&quot;Active&quot;).Where(x =&gt; x.Level == 1).ToList(), null, &quot;category&quot;);
                  ViewData[&quot;StatusDropDown&quot;] = CommonUtils.CommonUtils.GetDropDownByType(_common.GetAllActiveStatus(), null, &quot;status&quot;);
                  ViewData[&quot;AttributesDropDown&quot;] = CommonUtils.CommonUtils.GetDropDownByType(_attributes.GetAllAttributes(), null, &quot;attributes&quot;);
                  return View(container);
              }
              catch(Exception ex)
              {
                  _common.SaveErrorLog(ex.ToString());
                  ProductViewModel container = new ProductViewModel();
                  container.Heading = new HeadingModel();
                  container.Heading.MainHeading = &quot;Product Management&quot;;
                  container.Heading.SubHeading = &quot;Addd new products for your store&quot;;
                  ViewData[&quot;BrandDropDown&quot;] = CommonUtils.CommonUtils.GetDropDownByType(_brand.GetAllBrandsByType(&quot;Active&quot;), null, &quot;brand&quot;);
                  ViewData[&quot;TaxDropDown&quot;] = CommonUtils.CommonUtils.GetDropDownByType(_tax.GetAllTaxesForDropDown(string.Empty), null, &quot;tax&quot;);
                  ViewData[&quot;CategoryDropDown&quot;] = CommonUtils.CommonUtils.GetDropDownByType(_category.GetCategoriesByStatus(&quot;Active&quot;).Where(x =&gt; x.Level == 1).ToList(), null, &quot;category&quot;);
                  ViewData[&quot;StatusDropDown&quot;] = CommonUtils.CommonUtils.GetDropDownByType(_common.GetAllActiveStatus(), null, &quot;status&quot;);
                  ViewData[&quot;AttributesDropDown&quot;] = CommonUtils.CommonUtils.GetDropDownByType(_attributes.GetAllAttributes(), null, &quot;attributes&quot;);
                  ViewData[&quot;SuccessFormMessage&quot;] = string.Empty;
                  ViewData[&quot;ErrorFormMessage&quot;] = &quot;Something went wrong in our end&quot;;
                  return View(container);
              }
  </code></pre>