Mukesh

Mukesh

  • NA
  • 228
  • 42.7k

How to use multiple file upload in two fileupload control

Mar 25 2017 1:49 AM
$(document).ready1(function () {

// up to 3 files can be selected

// invoke plugin
$('#ctl00_ContentPlaceHolder1_flpProspectus').MultiFile(5);

// if you send in a number the plugin
// will treat it as the file limit

});
$(document).ready2(function () {

// up to 3 files can be selected

// invoke plugin
$('#ctl00_ContentPlaceHolder1_flpEnquiry').MultiFile(5);

// if you send in a number the plugin
// will treat it as the file limit

});
<asp:FileUpload ID="flpProspectus" class="form-control" runat="server" Style="width: 50%; margin-top: -50px;float:left; margin-left:90%" />
<asp:FileUpload ID="flpEnquiry" class="form-control" runat="server" Style="width: 50%; margin-top: -50px;float:left; margin-left:90%" />

Cs Page code---
public void FileUpload1()
{
if (flpOrientation.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++)
{
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 path = "college/fileupload3/" + hpf.FileName;
if (i < 5)
{
arr[i] = path;
path1 = arr[0]; path2 = arr[1]; path3 = arr[2]; path4 = arr[3]; path5 = arr[4];

}

}
}
}
}



Above I mention Code-
I Want to know When i Just Choose File From FileUpload Control it is working Fine
but when i Choose one File From First File Control and One Choose File From Second FileUpload Control Then Both File is Stored in Same Folder and my Loop Condition working for both control so how to solve this issue when i choose First FileUpload Control then My Loop Condition Only Work First Control So Please Help Me-

I am Using File Upload Code of This Link--

jQuery MultiFile v2.2.1[^]

Answers (1)