On 16/05/07, Micky Hulse <[EMAIL PROTECTED]> wrote:
Hi folks, I hope everyone is having a good week. :)

Let me cut to the chase... Basically, I need to get this:

http://www.site.com/folder/foo

To work like this:

$_SERVER['DOCUMENT_ROOT'].'folder/foo/file.ext';

For use with getimagesize() and a few other functions (trying to avoid
possible open_basedir restrictions.) Here is what I got so far:

# Determine http type:
$http_s = ($_SERVER['HTTPS'] == on) ? 'https://' : 'http://';
# Get root path:
$from_root = str_replace($http_s.$_SERVER['SERVER_NAME'], '',
http://www.site.com/folder/foo);
echo
$_SERVER['DOCUMENT_ROOT'].$from_root;
/*
** Output:
** /web1/httpd/htdocs/blogs/images/uploads
*/

So, do you think I can rely upon the above script? I have a feeling the
answer will be no.... Or, anyone have any tips/improvements?

use parse_url()

http://www.php.net/parse_url

then append the 'path' part to document root ?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to