FileUpload "Rooted" error
I am trying to create a simple FileUpload control to allow a user to upload pictures to a "pictures" folder. I have to admit, I have very little experience with creating sites, and how this would work in production. I tried the below function and get the following error:
The SaveAs method is configured to require a rooted path, and the path '~/Pictures/memberback.jpg' is not rooted.
1) What am I doing wrong?
2) Is it your experience that, if I host this with a company (such as GoDaddy) do these companies usually allow for you to upload this way to a directory?
Thanks, in advance,
Rob
Protected Sub uploadButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uploadButton.Click
If FileUpload1.HasFile Then
Try
FileUpload1.SaveAs("~/Pictures/" & FileUpload1.FileName)
Catch ex As Exception
FileUploadReport.Text = "Failed because: <br/>" & ex.Message
End Try
Else
FileUploadReport.Text = "Please select a file before clicking the Upload Button"
End If
End Sub
|