User-271186128 posted
Hi Bakhtawar Ashiq,
According to your description, I suggest you could refer to the following code to display the file name and insert them into database.
<asp:FileUpload ID="fileUpEx" runat="server" AllowMultiple="true" /><br />
<asp:Label ID="Label1" runat="server" Text=""></asp:Label><br />
<asp:Button ID="btnAddFile" runat="server" OnClick="btnAddFile_Click" Text="Add file name to Label" /><br />
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Insert file into database" /><br />
Code behind:
'use a list to store the selected file name.
Protected Shared itemList As List(Of String) = New List(Of String)
Protected Sub btnAddFile_Click(sender As Object, e As EventArgs)
If fileUpEx.HasFiles Then
For Each uploadedfile As HttpPostedFile In fileUpEx.PostedFiles
itemList.Add(uploadedfile.FileName)
Next
'When display the file name, use Join method to join the file name and add line feed
Label1.Text = String.Join("<br/>", itemList)
End If
End Sub
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs)
'loop through the list and insert the file name into database.
For Each filepath As String In itemList
//insert into database
Next
End Sub
Best regards,
Dillion