使用()控件的saveas方法可以将上传文件保存到服务器.,3.25.1 使用FileUpload控件上传文件...

VB

Protected Sub Button1_Click(ByVal sender

As Object, ByVal e As System.EventArgs)

If FileUpload1.HasFile Then

Try

FileUpload1.SaveAs("C:\Uploads\" &

FileUpload1.FileName)

Label1.Text="File name: "&

FileUpload1.PostedFile.FileName & "
" &

"File Size: " & _

FileUpload1.PostedFile.ContentLength & " kb
" &

"Content type: " &

FileUpload1.PostedFile.ContentType

Catch ex As Exception

Label1.Text="ERROR: "& ex.Message.ToString()

End Try

Else

Label1.Text="You have not specified a file."

End If

End Sub

FileUpload Server Control

OnClick="Button1_Click"/>