Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get server path of physical path ?

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 ?

like image 467
Freshblood Avatar asked Jun 22 '11 07:06

Freshblood


People also ask

What is the server path?

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).

What is a physical path?

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.

What is virtual path and physical path?

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.


1 Answers

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); 
like image 172
Tomasz Jaskuλa Avatar answered Sep 22 '22 13:09

Tomasz Jaskuλa