Home > Software engineering >  File upload to vb.net how to upload the extension of the file name and path to the database
File upload to vb.net how to upload the extension of the file name and path to the database

Time:09-27

How after clicking the save operation will upload the source file name and path to the file saved to the database
Protected Sub Button_FileUpload1_Click (ByVal sender As Object, ByVal e the As System. EventArgs)
Dim IntlsUF As Integer
IntlsUF=1
IF the file. HasFile=true THen
Dim strFileTName As String
StrFileTName=file. PostedFile. FileName
Try
File. SaveAs (Server. MapPath (" ~/legacy/TEST/TEST/") + strFileTName)
Catch the ex As Exception
'IntlsUF=0
Label1. Text=IntlsUF. ToString
End the Try
If IntlsUF=1 then
Label1. Text="file upload success"
Label1. Text +="& lt; Br/& gt;"
Label1. Text +="& lt; Li>" + "the original file path:" + strFileTName
The Else
Label1. Text="file upload failed" + IntlsUF. ToString
End the If
End the If

End Sub



Protected Sub Button_Save_Click (ByVal sender As Object, ByVal e the As System. EventArgs)
Me. Button_Save. Enabled=False
If Me. TextBox_Insert_Customer. Text & lt;> "" Then
Me. TextBox_Insert_Customer. Text=Me. TextBox_Insert_Customer. Text. Trim
Me. TextBox_Insert_Customer. Text=Me. TextBox_Insert_Customer. Text. The ToUpper
End the If
If Me. TextBox_Insert_RPTID. Text & lt;> "" Then
Me. TextBox_Insert_RPTID. Text=Me. TextBox_Insert_RPTID. Text. Trim
Me. TextBox_Insert_RPTID. Text=Me. TextBox_Insert_RPTID. Text. The ToUpper
End the If
Try
Me. SdDaily_Manage. Insert ()
Me. GvDaily_Mange. DataBind ()
Catch the ex As Exception
'MsgBox (ex. Message)
Me. ClientScript. RegisterStartupScript (Me. GetType (), "Startup", BuildWarning (ex. Message))
'Response. Write (ex. Message)
'the Response. The End
End the Try
Me. TextBox_Insert_Customer. Text=""
Me. TextBox_Insert_RPTID. Text=""
Me. TextBox_Insert_Description. Text=""
Me. Button_Save. Enabled=True
End Sub
  • Related