PHP Directory Base, need help please

by 8 replies
9
Hey, so I've encountered a problem with my php/html/css website.
I've created a secondary folder. My files in that secondary folder includes the footer.php and the header.php from the root directory, but unfortunetaly the images those 2 files calls don't appear in the page of my secondary folder, since the directory of those images in is my image folder in my root directory.

How can I fix this?

Thanks.
#programming #base #directory
  • We would need to see how your image code currently is. More specifically, the href.

    What does one of your images currently look like in html? As in:

    <img src="images/image.png" alt="My Image" />
    • [1] reply
    • Yeah it looks exactly as an normal image link.

      <img src="http://www.warriorforum.com/images/logo.png" alt="My Image" />
      (without http://www.warriorforum.com/)

      This is located in my header.php file, which is in my root folder. The images folder is also located in my root folder.

      Thanks
  • anyone? this looks really simple but I'm really having trouble with it.
  • Banned
    [DELETED]
    • [1] reply
    • Hey,

      Try this,

      <img src="../images/sample.jpg">

      This might solve your problem.
  • I believe you guys did not understand what I meant.

    In my root folder, I have my header.php and my index.php.
    I've created a secondary folder in my root folder called "letters".

    Both my index.php and the files in my "letters" folder calls back my header.php file to display the header.

    I store my images in a folder called "images" in my root directory.

    The code in my header file is <img src='images/logo.png' /> (" instead of ')

    It works perfectly for my index.php file, however the index of my "letters" folder doesn't display the images since the proper code would be <img src="../images/logo.png" /> since the images are located one level down in the directory.

    Now my question would be how would I achieve this?
  • Check the PHP syntax but your config.php file can have a "images" variable that you can reference.

    $img_folder = "http://yourwebsite/images/";

    OR

    $img_folder = "/home/username/public_html/website/images/"; blah blah blah

    and then later on:

    img src=$img_folder."logo.png" />

    Or something to that effect. Always try to write modular code. Even though your variable has the full url path the optimizer will do it's magic and the internal link structure used by PHP should be simpler. Yeah. . ... right, that's the ticket. . .... I think.
  • Hello


    <img src="../images/sample.jpg">

    Try this solution it may be solved your problems.
  • Do as the previous poster said, or use the full path:
    Code:
    <img src="http://yourwebsite.com/images/sample.jpg">

Next Topics on Trending Feed

  • 9

    Hey, so I've encountered a problem with my php/html/css website. I've created a secondary folder. My files in that secondary folder includes the footer.php and the header.php from the root directory, but unfortunetaly the images those 2 files calls don't appear in the page of my secondary folder, since the directory of those images in is my image folder in my root directory.