SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_SERVER['DOCUMENT_ROOT'] problem...

    Hello all,

    Basically i am trying to use the $_SERVER['DOCUMENT_ROOT'] feature, with little success.

    I have set to "C:\Inetpub\wwwroot\" in my php.ini file...

    i want to be able to just upload the site when finished so was trying to do something like this...

    <img src="<?php echo $_SERVER['DOCUMENT_ROOT'] . '/images/ball.gif' ;?>" width="200" height="200" alt="none" />

    i have used phpinfo() and it shows no value even though its set in the php.ini file...?

    any suggestions...

    thanks,

  2. #2
    SitePoint Addict miggl's Avatar
    Join Date
    Feb 2007
    Location
    Los Angeles, CA
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $_SERVER['DOCUMENT_ROOT'] has been documented to not work in IIS. You will need to employ a work-around in your code. This can be done by getting the current script path, and working you way up the folders while comparing it to the URL. As long as the sub-folders of the URL match the current folder of the path, keep chopping off a sub-folder. As soon as the current path folder and current url folder do not match, you should be at the root.
    You can then place this result in $_SERVER['DOCUMENT_ROOT'] in your code.

    Good luck!
    Mike
    Celebrate Liberty, Freedom, and Rights at The Constitutionalist.

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    <img src="<?php echo $_SERVER['DOCUMENT_ROOT'] . '/images/ball.gif' ;?>" width="200" height="200" alt="none" />
    Will not work regardless if DOCUMENT_ROOT works in IIS.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Addict miggl's Avatar
    Join Date
    Feb 2007
    Location
    Los Angeles, CA
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    Will not work regardless if DOCUMENT_ROOT works in IIS.
    This is true. DOCUMENT_ROOT will only work on server-side code.
    Celebrate Liberty, Freedom, and Rights at The Constitutionalist.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •