How to upload a file, save its Filename

Create a form, add a button upload and a fileupload

add a datasource with insert script.

Code Behind:

Protected Sub Buttonupload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonupload.Click
Dim str As String

str = FileUploadcontrol.FileName.ToString()
FileUploadcontrol.SaveAs("FolderLocation" & str.ToString)

 

SqlDataSourcecontrol.InsertParameters("Categoryid").DefaultValue = DropDownListcategory.SelectedValue
SqlDataSourcecontrol.InsertParameters("Question").DefaultValue = TextBox1.Text
SqlDataSourcecontrol.InsertParameters("filename").DefaultValue = str.ToString
SqlDataSourcecontrol.Insert()
TextBoxQuestion.Text = ""
End Sub

Related Posts

No Comments Yet.

Leave a reply

You must be logged in to post a comment.