How to upload file using ASP.NET?

Question

How to upload file using ASP.NET?

Re: How to upload file using ASP.NET?

Sub Upload(Source As Object, e As EventArgs)

If Not (myFile.PostedFile Is Nothing) Then

Dim intFileNameLength as Integer
Dim strFileNamePath as String
Dim strFileNameOnly as String

'Logic to find the FileName (excluding the path)
strFileNamePath = MyFile.PostedFile.FileName
intFileNameLength = Instr(1, StrReverse(strFileNamePath), "\")
strFileNameOnly = Mid(strFileNamePath, (Len(strFileNamePath)-intFileNameLength)+2)

myFile.PostedFile.SaveAs("c:\inetpub\wwwroot\yourwebapp\upload\" & strFileNameOnly)
lblMsg.Text = "File Upload Success."

End If
End Sub

File Upload

File: