Solved

Converting virtual path to physical path

Posted on 2004-03-22
7
468 Views
Last Modified: 2013-11-15
how can get the physical path given the virtual path (http://abc.com/main/)? something like server.mappath() in asp.



Regards
Renjith
0
Comment
Question by:renjith
  • 2
7 Comments
 
LVL 6

Expert Comment

by:Reapz
ID: 10650030
To get the physical path of the current path you would do...

$path = $_SERVER['DOCUMENT_ROOT'];

... if that helps.
0
 
LVL 6

Expert Comment

by:Reapz
ID: 10650043
I meant to get the physical path of the the current document... Sigh... time for more coffee!
0
 
LVL 10

Accepted Solution

by:
frugle earned 25 total points
ID: 10650593
$_SERVER['PATH_TRANSLATED'] #gives the filesystem based path to the current script, after the server has done any virtual-to-real mapping.

Mike
0
 
LVL 6

Assisted Solution

by:CosminB
CosminB earned 25 total points
ID: 10655443
try this:
<?php
echo __FILE__; // this will give you the absolute path of your file
echo dirname(__FILE__); //this will give you the absolute path of the folder in which your file is located
?>

as for Reapz's answer $_SERVER['DOCUMENT_ROOT'] will give the absolute path of where your web server root is located(the files that will be accessed from "http://somedomain.com/" - that's why it's called document root)
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
In this article we will learn how to backup a VMware farm using Nakivo Backup & Replication. In this tutorial we will install the software on a Windows 2012 R2 Server.
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question