天天看點

使用()控件的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"/>