Html Code
<input type=file runat="server" id="myFile1" />
Server Side Code
Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Dim file1 As String = ""
file1 = UploadFile(myFile1)
End Sub
Private Function UploadFile(ByVal myfile As HtmlInputFile) As String
Dim file As String = ""
If Not myfile.PostedFile Is Nothing Then
Dim filepath As String = myfile.PostedFile.FileName
If filepath <> "" Then
file = System.IO.Path.GetFileName(myfile.PostedFile.FileName)
Try
myfile.PostedFile.SaveAs(Server.MapPath(".\Files\") & file)Catch ex As Exception
lblErr.Text = ex.Message
End Try
End If
End If
Return file
End Function