By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,870 Members | 2,347 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,870 IT Pros & Developers. It's quick & easy.

Upload file to web server

P: 374
Can anyone tell me how to upload a file to a web server ?
i know how to save it on my computer.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Submit1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit1.ServerClick
  2.         If Not File1.PostedFile Is Nothing And File1.PostedFile.ContentLength > 0 Then
  4.             Dim fn As String = System.IO.Path.GetFileName(File1.PostedFile.FileName)
  5.             Dim SaveLocation As String = MapPath("") & "/" & fn
  6.             Try
  7.                 File1.PostedFile.SaveAs(SaveLocation)
  8.                 Response.Write("The file has been uploaded.")
  9.             Catch Exc As Exception
  10.                 Response.Write("Error: " & Exc.Message)
  11.             End Try
  12.         Else
  13.             Response.Write("Please select a file to upload.")
  14.         End If
  15.     End Sub
i want to get the file on the web hosts pc.
May 12 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.