0

I have two file upload control with different name and id. But when i am uploading multiple file ,i am receiving only one file of each control. Below is my code. Main View

@using (Ajax.BeginForm("Questionnaire", "Tax", new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "divQuestionnaire" }, new { id = "formquestionnaire", enctype = "multipart/form-data" }))
        {
        <div class="clearfix" id="divQuestionnaire">
        @{ Html.RenderPartial("_Questionnaire");}
        </div>
        }

Partial view where file upload control is placed

 <input id="PhotoUrl" type="file" class="upload" multiple="multiple" name="PhotoUrl" />
      <input id="AddressUrl" type="file" class="upload" multiple="multiple" name="AddressUrl" />
     <button  type="submit">Save</button>  

controller

  public ActionResult Questionnaire(HttpPostedFileBase[] PhotoUrl, HttpPostedFileBase[] AddressUrl)
        {
}

also tryied this not working

  public ActionResult Questionnaire(IEnumerable<HttpPostedFileBase> PhotoUrl, IEnumerable<HttpPostedFileBase> AddressUrl)
        {       
        }
user1681166
  • 221
  • 2
  • 5
  • 15
  • If this approach is not working, please have a look at [this answer](http://stackoverflow.com/a/38349541/3814721). By using this you can upload multiple files as well. – mmushtaq Apr 07 '17 at 10:24
  • if I select multiple file at a same time and submit the button ,then i am able to fetch all selected file .But if i select one file,and again one file,only last file selected is only able to access through controller – user1681166 Apr 07 '17 at 10:32
  • You cannot upload files using `Ajax.BeginForm()` so not sure how your claiming your getting one. You can however use `$.ajax() with `FormData` - refer [this answer](http://stackoverflow.com/questions/29293637/how-to-append-whole-set-of-model-to-formdata-and-obtain-it-in-mvc/29293681#29293681) –  Apr 07 '17 at 11:49

0 Answers0