Reputation: 11137
i use to upload a photo to a server this piece of code:
uplTheFile.PostedFile.SaveAs(Path);
But the Path can't be relative (like ~\\Photos\\image.jpg
) .
I was thinking of getting the location of the .aspx file from where i upload the image and attach \\Photos\\image.jpg
to it, but i don't know how to get the address (location ) of my .aspx page on the server .
Can someone help?
Upvotes: 0
Views: 1305
Reputation: 40149
Server.MapPath("~/Photos/image.jpg");
That will give you the physical path. You could have the aspx file name in there if you wanted:
Server.MapPath("~/mypage.aspx");
The Page
object also has a property that points to the template file (the aspx)
Upvotes: 3