Re: [PHP] linking to an image with document_root

2007-06-02 Thread Richard Lynch


On Fri, June 1, 2007 6:33 pm, chris smith wrote:
 On 6/2/07, Richard Lynch [EMAIL PROTECTED] wrote:
 On Fri, June 1, 2007 3:16 am, blueboy wrote:
  May be a stupid question but can I link to images with doscument
 root
 
  $img_url= $_SERVER['DOCUMENT_ROOT'].'/images/holder.gif';
 
  echo img src=\$img_url\ width=\250\ height=\163\/;
 
  I am certain the path is correct,
 
  If not what are my alternatives?

 You could try if faster than you'll get an answer here, but, yes,
 you
 could do that.

 You may even want to set up a variable called $IMAGE_ROOT and set it
 to $_SERVER['DOCUMENT_ROOT'] in a config/include file, so that if
 you
 ever want to move all your images somewhere else, you only change
 one
 line of code.

 How's that going to help when the OP is using a *file path* as an
 image source ?

Because if he tries it, he'll find out it wont' work.

And if he has it only ONE place to fix, then that's better than having
it all over his site, once he finds out that DOCUMENT_ROOT is wrong,
but something like HTTP_HOST is right.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] linking to an image with document_root

2007-06-02 Thread Richard Lynch
On Fri, June 1, 2007 8:37 pm, Tom Rogers wrote:
 Friday, June 1, 2007, 6:16:34 PM, you wrote:
 b May be a stupid question but can I link to images with doscument
 root

 b $img_url= $_SERVER['DOCUMENT_ROOT'].'/images/holder.gif';

 b echo img src=\$img_url\ width=\250\ height=\163\/;

 b I am certain the path is correct,

 b If not what are my alternatives?


 b R.


 You don't need anything other than the first slash and it will be from
 the root of the web site. So all you need is:
 $url = '/images/holder.gif';

 and it will come from http://whatever.com/images/holder.gif

That actually relies on the browser to fill in the domain, and it's a
Documented Feature so that's fine...

But if you have dreams of scaling up to zillions of users, setting
this up right so that you can flip all your images to separate boxes
(or dcn or akami-like or...) is probably a Good Idea.

It will only take a few minutes' work, and some discipline on an
ongoing basis, but it's not hard by any means.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] linking to an image with document_root

2007-06-01 Thread Chris

blueboy wrote:

May be a stupid question but can I link to images with doscument root

$img_url= $_SERVER['DOCUMENT_ROOT'].'/images/holder.gif';

echo img src=\$img_url\ width=\250\ height=\163\/;


An image source is the URL to that image.

The server document root is the local location of that file (eg 
/home/user/file.gif) - which is never going to work as a URL.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] linking to an image with document_root

2007-06-01 Thread Shafiq Rehman

Hi,

You cannot use document_root to get the paths for images. You can write a
function to get the images url in your application.

function imageServer()
{
  return /images/;
}

--
Shafiq Rehman (ZCE)
http://www.phpgurru.com | http://shafiq.pk
Cell: +92 300 423 9385


On 6/1/07, Chris [EMAIL PROTECTED] wrote:


blueboy wrote:
 May be a stupid question but can I link to images with doscument root

 $img_url= $_SERVER['DOCUMENT_ROOT'].'/images/holder.gif';

 echo img src=\$img_url\ width=\250\ height=\163\/;

An image source is the URL to that image.

The server document root is the local location of that file (eg
/home/user/file.gif) - which is never going to work as a URL.

--
Postgresql  php tutorials
http://www.designmagick.com/

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




[PHP] linking to an image with document_root

2007-06-01 Thread blueboy
May be a stupid question but can I link to images with doscument root

$img_url= $_SERVER['DOCUMENT_ROOT'].'/images/holder.gif';

echo img src=\$img_url\ width=\250\ height=\163\/;

I am certain the path is correct,

If not what are my alternatives?


R. 

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



Re: [PHP] linking to an image with document_root

2007-06-01 Thread clive

blueboy wrote:

May be a stupid question but can I link to images with doscument root

there are no stupid questions, only stupid answers.


$img_url= $_SERVER['DOCUMENT_ROOT'].'/images/holder.gif';


no you cant;

do this in a script on your server:

echo pre;
print_r($_SERVER);

and have look at the variables you can make use of, I would imagine 
$_SERVER[SERVER_NAME] might be the ones you want.


clive



echo img src=\$img_url\ width=\250\ height=\163\/;

I am certain the path is correct,

If not what are my alternatives?


R. 




--
Regards,

Clive.

Real Time Travel Connections


{No electrons were harmed in the creation, transmission or reading of 
this email. However, many were excited and some may well have enjoyed 
the experience.}


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



Re: [PHP] linking to an image with document_root

2007-06-01 Thread Richard Lynch
On Fri, June 1, 2007 3:16 am, blueboy wrote:
 May be a stupid question but can I link to images with doscument root

 $img_url= $_SERVER['DOCUMENT_ROOT'].'/images/holder.gif';

 echo img src=\$img_url\ width=\250\ height=\163\/;

 I am certain the path is correct,

 If not what are my alternatives?

You could try if faster than you'll get an answer here, but, yes, you
could do that.

You may even want to set up a variable called $IMAGE_ROOT and set it
to $_SERVER['DOCUMENT_ROOT'] in a config/include file, so that if you
ever want to move all your images somewhere else, you only change one
line of code.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] linking to an image with document_root

2007-06-01 Thread chris smith

On 6/2/07, Richard Lynch [EMAIL PROTECTED] wrote:

On Fri, June 1, 2007 3:16 am, blueboy wrote:
 May be a stupid question but can I link to images with doscument root

 $img_url= $_SERVER['DOCUMENT_ROOT'].'/images/holder.gif';

 echo img src=\$img_url\ width=\250\ height=\163\/;

 I am certain the path is correct,

 If not what are my alternatives?

You could try if faster than you'll get an answer here, but, yes, you
could do that.

You may even want to set up a variable called $IMAGE_ROOT and set it
to $_SERVER['DOCUMENT_ROOT'] in a config/include file, so that if you
ever want to move all your images somewhere else, you only change one
line of code.


How's that going to help when the OP is using a *file path* as an image source ?

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] linking to an image with document_root

2007-06-01 Thread Tom Rogers
Hi,

Friday, June 1, 2007, 6:16:34 PM, you wrote:
b May be a stupid question but can I link to images with doscument root

b $img_url= $_SERVER['DOCUMENT_ROOT'].'/images/holder.gif';

b echo img src=\$img_url\ width=\250\ height=\163\/;

b I am certain the path is correct,

b If not what are my alternatives?


b R. 


You don't need anything other than the first slash and it will be from
the root of the web site. So all you need is:
$url = '/images/holder.gif';

and it will come from http://whatever.com/images/holder.gif

-- 
regards,
Tom

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