ASP.NET image/file upload?

XMEGA

New member
Hi, I am having trouble uploading images to my image folder I keep getting the message
error on upload:
The given path's format is not supported.

this is for the on_click even for upload button

If txtFileUpload.PostedFile.ContentLength = 0 Then
lblMessage.Text = "File does not exist"
Else
' takes filename if nothing in textbox
If txtServerFileName.Text Is Nothing Or txtServerFileName.Text.Trim() = "" Then
txtServerFileName.Text = txtFileUpload.PostedFile.FileName
End If
txtServerFileName.Text = txtServerFileName.Text.Trim

Try
Dim path As String = Server.MapPath("~/images")
txtFileUpload.PostedFile.SaveAs(path & "\" & txtServerFileName.Text)

lblMessage.Text = "Upload worked to :<br/>" & path & "\" & txtServerFileName.Text

' link to the image just uploaded
hypClickHere.Visible = True
hypClickHere.NavigateUrl = "~/images/" & txtServerFileName.Text

Catch ex As Exception
lblMessage.Text = "error on upload: <br/>" & ex.Message
End Try

End If
 
Back
Top