Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 529
  • Last Modified:

Converting virtual path to physical path

how can get the physical path given the virtual path (http://abc.com/main/)? something like server.mappath() in asp.



Regards
Renjith
0
renjith
Asked:
renjith
  • 2
2 Solutions
 
AndyCommented:
To get the physical path of the current path you would do...

$path = $_SERVER['DOCUMENT_ROOT'];

... if that helps.
0
 
AndyCommented:
I meant to get the physical path of the the current document... Sigh... time for more coffee!
0
 
frugleCommented:
$_SERVER['PATH_TRANSLATED'] #gives the filesystem based path to the current script, after the server has done any virtual-to-real mapping.

Mike
0
 
CosminBCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now