question regarding multiple file upload
i am uploading multiple files from a asp.net form which have 5 panels
2nd panel i am select 5 files to upload and the 5th panel i am submitting
i am saving the file like below in panel 2
ObjFileUploader1 = (FileUpload)Session["FileUpload1"];
ObjFileUploader2 = (FileUpload)Session["FileUpload2"];
ObjFileUploader3 = (FileUpload)Session["FileUpload3"];
ObjFileUploader4 = (FileUpload)Session["FileUpload4"];
ObjFileUploader5 = (FileUpload)Session["FileUpload5"];
i need to iterate through this ObjFileUploader objects when submitting files
currenlty i am doing like below
if (temp != 0 && ObjFileUploader1 != null && ObjFileUploader1.HasFile)
{
upload the file to server
}
if (temp != 0 && ObjFileUploader1 != null && ObjFileUploader2.HasFile)
{
upload the file to server
}
i want to loop through all the ObjFileUploader in one time
how to do
please help me
Thanks
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Hiten PandyaPosted Feb 14, 2018, 11:55 PM
There is a way that you can store that all files into an array or arraylist or list of string and then can easily iterate over them. You have use session and there is only change of one digit from these 5 sessions so you can write something like this,
string a = "a";
string b = "b";
string c = "c";
string d = "d";
string f = "f";
Session["str1"] = a;
Session["str2"] = b;
Session["str3"] = c;
Session["str4"] = d;
Session["str5"] = f;
ArrayList arr = new ArrayList();
for (int i = 1; i <= 5; i++)
{
arr.Add(Session["str" + i + ""].ToString());
}
for (int j = 0; j < arr.Count; j++)
{
//Here you can use your fileuploads for further process.
}
Hope it helps you.
Thanks.