т.е. выбор файла и кнопку "Upload File"
на одной html-странице (1)
а обработку полученного на сервер файла процедурой
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack Then
Dim path As String = Server.MapPath("~/UploadedImages/")
Dim fileOK As Boolean = False
If uploadedfile.HasFile Then
Dim fileExtension As String
fileExtension = System.IO.Path.GetExtension(uploadedfile.FileName).ToLower()
Dim allowedExtensions As String() = {".jpg", ".jpeg", ".png", ".gif"}
For i As Integer = 0 To allowedExtensions.Length — 1
If fileExtension = allowedExtensions(i) Then
fileOK = True
End If
Next
If fileOK Then
Try
uploadedfile.PostedFile.SaveAs(path & uploadedfile.FileName)
Label1.Text = "File uploaded!"
Catch ex As Exception
Label1.Text = "File could not be uploaded."
End Try
Else
Label1.Text = "Cannot accept files of this type."
End If
End If
End If
End Sub