Solved

Converting virtual path to physical path

Posted on 2004-03-22
7
463 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is an update and follow-up of my previous article:   Storage 101: common concepts in the IT enterprise storage This time, I expand on more frequently used storage concepts.
A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
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.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now