I want to convert this physical path "C:\bla\bla\Content\Upload\image.jpg"
to server path like "/Content/Upload/image.jpg"
.
How can i do that ?
A full server path is the path your system uses to define where your own files are located on the server (as opposed to files belonging to other users).
The physical path between two subarea nodes is an explicit route. Explicit route (ER) An explicit route is an ordered set of subarea nodes and transmission groups along a path between communicating subarea nodes, including: The endpoint subareas. Any subareas between the endpoint subareas.
Physical path - This is the actual path the file is located by IIS. Virtual path - This is the logical path to access the file which is pointed to from outside of the IIS application folder. Let's display this image from Hard-drive 'E' using a virtual directory in IIS Default web site.
you can use something like that :
public static class Extensions {
public static string RelativePath(this HttpServerUtility utility, string path, HttpRequest context)
{
return path.Replace(context.ServerVariables["APPL_PHYSICAL_PATH"], "/").Replace(@"\", "/");
}
}
and you call
Server.RelativePath(path, Request);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With