foreach (string fileName in Request.Files)
{
HttpPostedFileBase file = Request.Files[fileName];
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 times.
I use this control: https://github.com/kartik-v/bootstrap-fileinput
My cs.html
http://codepen.io/anon/pen/aekqm
Please find above my complete code.
source
share