Hi, I have a question about uploading multiple files using vb.net. I can select one file only to upload but need to save first before I can proceed to the next upload file. The reason I want to upload multiple because before I select the file, I need to insert the account no which is the unique id (cannot duplicate). So, my solution is upload multiple file at the same time by using same account no.
after I uploaded multiple files and check the database then only show 1 file save.
<tr>
<td>
<asp:DropDownList ID="ddl_bnkName" CssClass="form-control input-sm" runat="server"></asp:DropDownList>
<asp:HiddenField ID="hfaccno_id" runat="server" />
</td>
<td><asp:TextBox ID="bnkAcct" CssClass="form-control input-sm" runat="server"></asp:TextBox></td>
<td><asp:FileUpload ID="upl_bnkDocs" CssClass="form-control input-sm" runat="server" /></td>
<td><asp:Button ID="btn_bnkAdd" OnClick="btn_bnkAdd_Click" CssClass="btn btn-sm btn-primary" runat="server" Text="Add" /></td>
</tr>
vb code :
Protected Sub btn_bnkAdd_Click(sender As Object, e As EventArgs)
If Not retrievePerson.Value = "" Then
If ddl_bnkName.SelectedValue <> 0 Then
If bnkAcct.Text <> Nothing Then
Dim aDM As New PersonDM
aDM.assgnby = Session("UserID")
aDM.per_id = retrievePerson.Value
aDM.acc_no = bnkAcct.Text
aDM.branch_cd = Session("BranchID")
aDM.bank_id = ddl_bnkName.SelectedItem.Value
Dim path As String = UploadDocument(upl_bnkDocs, aDM.per_id, aDM.acc_no, ddl_bnkName.SelectedItem.Text)
aDM.doc_path = path
Dim bnkadSucc = PersonDB.InsertCIFAccNo(aDM)
If bnkadSucc.accno_id = 0 Then
UtilClass.AlertMessageStartupScripts(Me, "Bank account is already exists")
End If
PopulateRPTBnkAcctList()
ClearBankInfo()
Else
UtilClass.AlertMessageStartupScripts(Me, "Please insert account no")
End If
Else
UtilClass.AlertMessageStartupScripts(Me, "Please Select Bank")
End If
Else
UtilClass.AlertMessageStartupScripts(Me, "No Person ID")
End If
End Sub
upload script :
Private Function UploadDocument(ByVal upRpt As FileUpload, ByVal per_id As String, ByVal acct_no As String, ByVal bnk_name As String) As String
Dim retPath As String = Nothing
Dim PathToSave As String = UtilFolderAccess.CreateOutputFolderBank(per_id, "BANK_ACCNO")
Dim ext As String = System.IO.Path.GetExtension(upRpt.PostedFile.FileName)
Dim fileName As String = acct_no & "_" & bnk_name & ext
If upRpt.HasFile = True Then
If (System.IO.File.Exists(PathToSave & "\" & fileName)) = True Then
UtilClass.AlertMessageStartupScripts(Me, "A file with the same name already exists.")
retPath = Nothing
Else
Try
upRpt.SaveAs(PathToSave & "\" & fileName)
retPath = PathToSave & "\" & fileName
Catch ex As Exception
retPath = Nothing
End Try
End If
End If
Return retPath
End Function
So, here how to edit the code for that solution? Kindly help me. Appreciated if someone can help me. TQ