I have file upload and upload link button and submit button .. so when i select file and click on upload then file name display in label and when i again click on browse file and select file and click on upload then file name again save in label so means
multiple file name display in label i.e.
abc.docx
def.docx
.. and so on ..
now i try to save these files in database with different record means if these files save in database table then look like this
ID DocumentName DocumentPath
1 abc.docx /downloads/abc.docx
2 def.docx /files/def.docx
'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
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
239 Points
1074 Posts
Insert document name & document path in vb.net
Dec 28, 2016 11:58 AM|Capricon User|LINK
<div class="post-text" itemprop="text">
I have file upload and upload link button and submit button .. so when i select file and click on upload then file name display in label and when i again click on browse file and select file and click on upload then file name again save in label so means multiple file name display in label i.e.
.. and so on ..
now i try to save these files in database with different record means if these files save in database table then look like this
Index was outside the bounds of the array.
and how i insert also document path
any help ?
</div>
All-Star
45489 Points
7008 Posts
Microsoft
Re: Insert document name & document path in vb.net
Dec 29, 2016 05:37 AM|Zhi Lv - MSFT|LINK
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.
Code behind:
Best regards,
Dillion