Reputation: 13
$url = 'http://www.site.com/files/file.jpg';
How can I get the local path, like
C:\htdocs\site/files/file.jpg
?
Upvotes: 1
Views: 7229
Reputation: 3652
http://blabla.info/somepath/somefile.php
echo $_SERVER["SCRIPT_FILENAME"];
results in [/var/www/htdocs/blabla.info/somepath/somefile.php]
Cheers
Upvotes: 0
Reputation: 1302
You first get the document root of your site with
$_SERVER['DOCUMENT_ROOT'];
And then you append the relative path to your resource Ex:
$_SERVER['DOCUMENT_ROOT'] . '/relative/path/to/files/file.jpg';
Upvotes: 3
Reputation: 8528
If you're asking abut getting the local path of a document on a remote server that you don't have access to (other than HTTP), you can't.
If you're trying to get the path of a document on your server, you need an absolute or relative path to the root of the site and then you can derive the full path from there.
Upvotes: 1