www.webdeveloper.com
Results 1 to 2 of 2

Thread: Problem locating files in file system using php.

  1. #1
    Join Date
    May 2003
    Location
    Florida
    Posts
    38

    Problem locating files in file system using php.

    I am building a site using WAMP in windows 7 and I am having problems locating my css and image folder in my sub directories.

    I have multiple index.php files. I have 1 index.php file in the root of my site and also multiple sub folders which their own index.php file as well. I am using the "require_once" function to include header.php, footer.php, sidebar.php, etc and and all my index.php files are using these same included files regardless what level they're in in my folder tree.

    The problem is with my header.php file; because that is the file I'm using to link to my css stylesheet. I am successfully able to find the css file in my root index.php file but all my sub-folder index.php files ere not finding it.

    I've already discovered that by going into my header.php file and put a "../" in front will successfully work for all my sub-folder index.php files, but then my root index.php file doesn't find the css stylesheet anymore, and visa-versa.

    How can I get all my index.php files to see the css file regardless how deep or shallow they are in my file directory?

    I already know how to solve this problem if my site was already live on the internet, but I don't know how to solve it while I'm building it locally in WAMP. Can someone please help me? I hope I didn't confuse anyone...
    Jawaune Saad

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,241
    PHP Code:
    include $_SERVER['DOCUMENT_ROOT'] . '/path/to/file.php'
    So if, for instance, you have your WAMP config set up such that your web document root is at C:\Wamp\www, that would look for the include file as C:\Wamp\www\path\to\file.php.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles