Re: linking to an image with document_root

From: Date: Sat, 02 Jun 2007 17:38:08 +0000
Subject: Re: linking to an image with document_root
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-256011@lists.php.net to get a copy of this message
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\" > b> 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?

« previous php.general (#256011) next »