I am trying to implement a file upload in my web form, It tried this.
<asp:Label ID="lbl1" runat="server" Text="Press browse!"></asp:Label>
<br />
<br />
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<br />
<asp:Button ID="btnUpload" runat="server" Text="Upload" />
Protected Sub btnUpload_Click(sender As Object, e As EventArgs) Handles btnUpload.Click
If FileUpload1.HasFile Then
Try
FileUpload1.SaveAs("Images\" & FileUpload1.FileName)
lbl1.Text = "File name: " & _
FileUpload1.PostedFile.FileName & "<br>" & _
"File Size: " & _
FileUpload1.PostedFile.ContentLength & "<br>" & _
"Content type: " & _
FileUpload1.PostedFile.ContentType
Catch ex As Exception
lbl1.Text = "ERROR: " & ex.Message.ToString()
End Try
Else
lbl1.Text = "You have not specified a file."
End If
End Sub
But gives me an error saying file path is not rooted. I am running this locally at the moment and when I replace the file path with this 'C:Users/Me/Documents/MYPROJECTNAME/MYPROJECTNAME/Images' it works fine. This will go online so what am I meant to write as the file path?