Asp.net mvc uploads multiple image back-end storage,
The foreground page uploads images through the <file name = "img"> tag array. The background receives the images uploaded by the foreground according to Request. Files ["img.
1 System. web. httpFileCollection files = System. web. httpContext. current. request. files; 2 if (files. count = 0) 3 return false; 4 for (int I = 0; I <files. allKeys. count (); I ++) 5 {6 if (files. allKeys [I]! = "Img") 7 {8 if (files [I]. fileName. length> 0) 9 {10 System. web. httpPostedFile postedfile = files [I]; 11 string filePath = ""; 12 var ext = Path. getExtension (postedfile. fileName); 13 var fileName = DateTime. now. ticks. toString () + ext; 14 // relative path of the combined file storage 15 filePath = "/Upload/images/" + fileName; 16 // convert the relative path to the physical path 17 var path = Server. mapPath (filePath); 18 postedfile. saveAs (path); 19 string fex = Path. getExtension (postedfile. fileName); 20 // storage product carousel image information 21 product?usel model = new product=usel (); 22 model. productID = productID; 23 model. picSlider = filePath; 24 db. productdocumusels. add (model); 25 db. saveChanges (); 26} 27} 28 29}