Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am trying to do passing multiple upload file to controller. but i am not getting the Exact answer can you please help me for this.

What I have tried:

<form name='frmAccount' id='frmAccount'>
<input type='file' name='file1'/>  
<input type='file' name='file2'/>  
<input type='file' name='file3'/>  
<input type='file' name='file4'/>  
<input type='file' name='file5'/>  
<input type='file' name='file6'/>  
<input type='file' name='file7'/>  
<input type='submit' name='submit' />  
</form>
 
var formData = new FormData($('#frmAccount')[0]);  
        
        $.ajax({  
            url: "@Url.Action("AddCustomer", "Example")",  
            type: "POST",  
            data: formData ,  
            dataType: 'json',  
            contentType: false,  
            processData: false,  
            success: function (data) {  
                  
                }  
  
  
            },  
            error: function (xhr, desc, err) {  
  
  
            }  
        
        });  
  

public class ImageModel  
{  
 public HttpPostedFileBase file1{get;set;}  
 public HttpPostedFileBase file2{get;set;}  
 public HttpPostedFileBase file3{get;set;}  
 public HttpPostedFileBase file4{get;set;}  
 public HttpPostedFileBase file5{get;set;}  
 public HttpPostedFileBase file6{get;set;}  
 public HttpPostedFileBase file7{get;set;}  
  
  
}  


 [HttpPost]  
        public ActionResult AddCustomer(ImageModel model)  
        {  
              //i want to get all the files Here.   
         }  
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900