Riddhi Valecha

Riddhi Valecha

  • 422
  • 3.2k
  • 394.9k

Multiple File Upload - All files are not getting uploaded

Dec 3 2016 4:09 PM
Dear all,
 
I need to upload multiple files in the gridview, but I am not able to upload all the selected files on particular folder.
 
I am sharing my code and design.
 
Please guide - where am I going wrong now.
 

ASPX Page Design –

<head>

<title><title>

<link href=”App_Themes/Scripts/uploadify.css” rel=”stylesheet”/>

</head>

<body>

<script type=”text/javascript” src=” App_Themes/Scripts/jquery-.3.2.js”></script>

<script type=”text/javascript” src=” App_Themes/Scripts/jquery.Multifile.js”></script>

<form id=”form1” runat=”server”>

<table>

<tr>

<td>

<asp:radiobuttonlist id=”radiobtnlistSerialNumber” runat=”server”></asp:radiobuttonlist>

</td>

<td>

<asp:Fileupload id=”multiplefileupload” runat=”server” class=”multi”/>

</td>

</tr>

<tr>

<td>

<asp:radiobuttonlist id=”radiobtnlistSerialNumber” runat=”server”></asp:radiobuttonlist>

</td>

<tr>

<td colspan=”2”>

<asp:GridView id=”grdData” runat=”server” AutogenerateColumns=”true”>

</asp:GridView>

</td>

</tr>

<tr>

<td>

<asp:button id=”UploadFilesBtn” runat=”server” Text=”Upload Multiple Files” onClick=” UploadFilesBtn _Click”/>

</td>

</tr>

</table>

</form>

</body>

ASPX.cs file –

Protected void UploadFilesBtn _Click(object sender, EventArgs, e)

{

Try

{

HttpFileCollection hfc = Request.Files;

If(radiobtnlistSerialNumber.SelectedIndex >= 0)

{

If(multiplefileupload.HasFile == true)

{

Foreach(Gridviewrow row in grdData.Rows)

{

If(row.cells[2].text == radiobtnlistSerialNumber.Selectedvalue.tostring())

{

HttpFileCollection hcoll = Request.Files;

Int32 totalcount = hcoll.Count;

For(int i=0; I < totalcount-1; i++)

{

HttpPostedFile hpf =hcoll[i];

String s = ConfigurationManager.AppSettings[“UploadFolderPath”].ToString();

Multiplefileupload.PostedFile.SaveAs(s +”\\”+System.DateTime.Now.Tostring(“ddMMMyyyyhhmmss”) + multiplefileupload.FileName);

//Insert into table – values (radiobtnlistSerialNumber.Selectedvalue.tostring(),

//System.DateTime.Now.Tostring(“ddMMMyyyyhhmmss”) + multiplefileupload.FileName,

//Row.Cells[4].text.tostring());

}

}

}

}

}

}

}

Please guide - This is a bit urgent and important...

Answers (1)