mari muthu

mari muthu

  • NA
  • 198
  • 103.8k

Mvc Pass multiple upload file to controller using jquery

Apr 11 2018 5:01 AM
hi,
 
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.
  1. <form name='frmAccount' id='frmAccount'>  
  2. <input type='file' name='file1'/>  
  3. <input type='file' name='file2'/>  
  4. <input type='file' name='file3'/>  
  5. <input type='file' name='file4'/>  
  6. <input type='file' name='file5'/>  
  7. <input type='file' name='file6'/>  
  8. <input type='file' name='file7'/>  
  9. <input type='submit' name='submit' />  
  10. </form>  
  1. public class ImageModel  
  2. {  
  3. public HttpPostedFileBase file1{get;set;}  
  4. public HttpPostedFileBase file2{get;set;}  
  5. public HttpPostedFileBase file3{get;set;}  
  6. public HttpPostedFileBase file4{get;set;}  
  7. public HttpPostedFileBase file5{get;set;}  
  8. public HttpPostedFileBase file6{get;set;}  
  9. public HttpPostedFileBase file7{get;set;}  
  10. }  
  11. var formData = new FormData($('#frmAccount')[0]);  
  12. $.ajax({  
  13. url: "@Url.Action("AddCustomer", "Example")",  
  14. type: "POST",  
  15. data: formData ,  
  16. dataType: 'json',  
  17. contentType: false,  
  18. processData: false,  
  19. success: function (data) {  
  20. }  
  21. },  
  22. error: function (xhr, desc, err) {  
  23. }  
  24. });  
  25. [HttpPost]  
  26. public ActionResult AddCustomer(ImageModel model)  
  27. {  
  28. //i want to get all the files Here.  
  29. }  

Answers (7)