Hi,
I'm used to programming in ASP, and my site is hosted with a commercial host.
Can somebody please tell me how can I find out the physical rather than virtual path of file? i.e. in ASP I would use <%=Server.MapPath %>
Thanks!
<?php echo $_SERVER['PATH_TRANSLATED'] ?> will produce the same result aswell
After a search of php.net I was eventually successful, even though I didn't really know what exactly I was looking for!!
Actually, PATH_TRANSLATED doesn't work in all cases. PATH_TRANSLATED's little brother is called PATH_INFO and basically here's an example of how it works:
Imagine you have a PHP script that lets users download files on the server... but it does additional things like tracking usage and telling them "Your download will start momentarily". The name of your script will be retrieve.php.
To download a file, the requested file is added on to the end of it, for example:
Now the part following retrieve.php--the "/images/bill.jpg" part--is goes into $_SERVER['PATH_INFO'].
Now, $_SERVER['PATH_TRANSLATED'] is that part as an absolute path relative to the document root. In the previous example PATH_TRANSLATED would be something like /var/
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.