On Sunday 20 February 2005 12:15 pm, Dave wrote: > PHP General, > > The Situation: > I would like to be able to specify locations of scripts and files > relative to the "root" directory from which my web site is served. I > thought this was what $_SERVER['DOCUMENT_ROOT'] was for. > > The Problem: > When I use $_SERVER['DOCUMENT_ROOT'], it creates a path starting > from somewhere deep down in the server's file structure, below where I > even have authorized access. So if I specify a file like so: > $imageFile = $_SERVER['DOCUMENT_ROOT'] . "/images/image.jpg"; > ... PHP gets lost and doesn't locate it. > What I am looking for is a variable which will specify the base > directory that my web site is rooted in. In other words, starting from > the same directory that my index.html file is in. > > The Question: > How do I specify the directory that my web site is situated in, the > same directory where my main index.html file is? Is there a different > variable I should be using, or perhaps some configuration of > $_SERVER['DOCUMENT_ROOT'] that needs to be applied? > > What I've Tried So Far: > First I went to the on line PHP manual, which is where I found out > about $_SERVER['DOCUMENT_ROOT'] in the first place. Of all the server > variables available, 'DOCUMENT_ROOT' seems to describe what I'm looking > for, but doesn't behave how I would expect. > A Google search was equally ineffective in educating me in what > basic concept I am missing. > > Any advice would be much appreciated. > > -- > Dave Gutteridge > dave@xxxxxxxxxxxxxxx Hi Dave, Perhaps what you should do to set $imageFile = "/images/image.jpg" since I would assume, whatever your Document_Root is, 'images' is a sub-directory to it. I.e.: if your servable document directory is something like "/vhome/tokyocomedy/all_your_files_are_here" then "/vhome/tokyocomedy/all_your_files_are_here/images/image.jpg" is where your image.jpg file is. Also, check using <?php phpinfo(); ?> where the $_SERVER['DOCUMENT_ROOT'] is (under 'PHP Variables' section) and note where tempfiles are uploaded to as well, if you're uploading. HTh, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php