0

I have n number of multi file upload controls in a form. Is there any way to retrieve the multiple files uploaded on each of the input controls separately on submitting the form on asp.net MVC. Now, I'm getting all the files combined.

Note: : All these upload controls are dynamically added and not fixed

@using (Html.BeginForm("IpadUpload", "ReferenceDatabase", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <div id="multiple">
        <input type="file" class="multiple" name="files" multiple />
        <input type="file" class="multiple" name="files" multiple />
    </div>
    
    <button class="btn btn-default">Upload</button>
}

public FileResult IpadUpload(IEnumerable<HttpPostedFileBase> files)
{
}

enter image description here

After submitting enter image description here

Any suggestions on how to retrieve the multiple files uploaded on each of the input controls separately? I have googled a lot, but no hope

Community
  • 1
  • 1
Ramesh Vaasu
  • 86
  • 1
  • 8

1 Answers1

0

Try renaming your file input controls and having the below signature for method

@using (Html.BeginForm("IpadUpload", "ReferenceDatabase", FormMethod.Post,new { enctype = "multipart/form-data" }))
{    
<div id="multiple">
    <input type="file" class="multiple" name="filesControl1" multiple />
    <input type="file" class="multiple" name="filesControl2" multiple />
</div>

<button class="btn btn-default">Upload</button>
}

public FileResult IpadUpload(IEnumerable<HttpPostedFileBase> filesControl1, IEnumerable<HttpPostedFileBase> filesControl2 )
{
}
Dandy
  • 2,177
  • 14
  • 16