Request.Files same file getting uploaded asp.net mvc

asp.net-mvc, c#, file-upload, twitter-bootstrap

Solution

Solved my issue:

Used the code below

for (int i = 0; i < Request.Files.Count; i++)
{
    HttpPostedFileBase file = Request.Files[i];
}

instead of the foreach loop which was taking the same file twice

Problem

``` foreach (string fileName in Request.Files) { HttpPostedFileBase file = Request.Files[fileName]; //Save file content goes here fName = file.FileName; if (file != null && file.ContentLength > 0) { subPath = ConfigurationManager.AppSettings["SubPath"].ToString() + "/" + currentUserId; bool isExists = System.IO.Directory.Exists(Server.MapPath(subPath)); if (!isExists) System.IO.Directory.CreateDirectory(Server.MapPath(subPath)); string path = System.IO.Path.Combine(Server.MapPath(subPath), System.IO.Path.GetFileName(file.FileName)); file.SaveAs(path); } } ``` If i upload multiple files i get the same file n number of the times. I am using this control: https://github.com/kartik-v/bootstrap-fileinput My cs.html http://codepen.io/anon/pen/aekqm Please find above my complete code.

Original source