Mukesh

Mukesh

  • NA
  • 228
  • 42.7k

How to multiple file upload multi ASP file upload control on

Apr 5 2017 6:35 AM
public void FileUpload1()
{
if (flpProspectus.HasFile)
{

string fileExtension = System.IO.Path.GetExtension(flpProspectus.FileName);
int fileSize = flpProspectus.PostedFile.ContentLength;
HttpFileCollection hfc = Request.Files;
{
string[] arr = new string[5];

for (int i = 0; i < hfc.Count; i++)
{
if (hfc.GetKey(i) == "ctl00$ContentPlaceHolder1$flpProspectus")
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
hpf.SaveAs(Server.MapPath("~/College/fileupload3/") + System.IO.Path.GetFileName(hpf.FileName));
string filepath = Server.MapPath("~/College/fileupload3/");
string pathx = "~/College/fileupload3/" + hpf.FileName;
if (i < 5)
{
arr[i] = pathx;
path1 = arr[0]; path2 = arr[1]; path3 = arr[2]; path4 = arr[3]; path5 = arr[4];

}

}
}
}
}
}
}

public void FileUpload2()
{
if (flpOrientation.HasFile)
{
string fileExtension = System.IO.Path.GetExtension(flpOrientation.FileName);
int fileSize = flpOrientation.PostedFile.ContentLength;
HttpFileCollection hfc = Request.Files;
string[] arr = new string[5];
for (int i = 0; i < hfc.Count; i++)
{
if (hfc.GetKey(i) == "ctl00$ContentPlaceHolder1$flpOrientation")
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
hpf.SaveAs(Server.MapPath("~/College/fileupload4/") + System.IO.Path.GetFileName(hpf.FileName));
string filepath = Server.MapPath("~/College/fileupload4/");
string pathy = "fileupload4/" + hpf.FileName;
if (i < 5)
{
arr[i] = pathy;
path6 = arr[0]; path7 = arr[1]; path8 = arr[2]; path9 = arr[3]; path10 = arr[4];

}

}
}
}
}
}
public void FileUpload3()
{
if (flpEnquiry.HasFile)
{
string fileExtension = System.IO.Path.GetExtension(flpEnquiry.FileName);
int fileSize = flpEnquiry.PostedFile.ContentLength;
HttpFileCollection hfc = Request.Files;
string[] arr = new string[5];
for (int i = 0; i < hfc.Count; i++)
{
if (hfc.GetKey(i) == "ctl00$ContentPlaceHolder1$flpEnquiry")
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
hpf.SaveAs(Server.MapPath("~/College/fileupload5/") + System.IO.Path.GetFileName(hpf.FileName));
string filepath = Server.MapPath("~/College/fileupload5/");
string path = "fileupload5/" + hpf.FileName;
if (i < 5)
{
arr[i] = path;
path11 = arr[0]; path12 = arr[1]; path13 = arr[2]; path14 = arr[3]; path15 = arr[4];
}
}

}
}
}

}
public void FileUpload4()
{
if (flpPunishment.HasFile)
{
string fileExtension = System.IO.Path.GetExtension(flpPunishment.FileName);
int fileSize = flpPunishment.PostedFile.ContentLength;
HttpFileCollection hfc = Request.Files;
string[] arr = new string[5];
for (int i = 0; i < hfc.Count; i++)
{
if (hfc.GetKey(i) == "ctl00$ContentPlaceHolder1$flpPunishment")
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
hpf.SaveAs(Server.MapPath("~/College/fileupload6/") + System.IO.Path.GetFileName(hpf.FileName));
string filepath = Server.MapPath("~/College/fileupload6/");
string path = "fileupload6/" + hpf.FileName;
if (i < 5)
{
arr[i] = path;
path16 = arr[0]; path17 = arr[1]; path18 = arr[2]; path19 = arr[3]; path20 = arr[4];
}
}

}
}
}

}
public void FileUpload5()
{
if (flpnooffir.HasFile)
{
string fileExtension = System.IO.Path.GetExtension(flpnooffir.FileName);
int fileSize = flpnooffir.PostedFile.ContentLength;
HttpFileCollection hfc = Request.Files;
string[] arr = new string[9];
for (int i = 0; i < hfc.Count; i++)
{
if (hfc.GetKey(i) == "ctl00$ContentPlaceHolder1$flpnooffir")
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
hpf.SaveAs(Server.MapPath("~/College/fileupload7/") + System.IO.Path.GetFileName(hpf.FileName));
string filepath = Server.MapPath("~/College/fileupload7/");
string path = "fileupload7/" + hpf.FileName;
if (i < 5)
{
arr[i] = path;
path21 = arr[0]; path22 = arr[1]; path23 = arr[2]; path24 = arr[3]; path25 = arr[4];

}
}
}
}
}

}

What I have tried:

Above i Post You my Code i am using multiple time file upload i am facing problem
when i choose file for first asp control id-flpProspectus it is working fine
but when i choose file for second asp control id-flpOrientation it is not working properly i am using foreeach loop but not working

so please help me

Answers (2)