PHP Directory Base, need help please

by lirikh
8 replies
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.
#base #directory
  • Profile picture of the author drewhowell21
    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" />
    {{ DiscussionBoard.errors[5188150].message }}
    • Profile picture of the author lirikh
      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
      {{ DiscussionBoard.errors[5188194].message }}
  • Profile picture of the author lirikh
    anyone? this looks really simple but I'm really having trouble with it.
    {{ DiscussionBoard.errors[5189034].message }}
  • Profile picture of the author bilclark229
    Banned
    [DELETED]
    {{ DiscussionBoard.errors[5189459].message }}
    • Profile picture of the author ramsarvan
      Hey,

      Try this,

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

      This might solve your problem.
      {{ DiscussionBoard.errors[5189722].message }}
  • Profile picture of the author lirikh
    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?
    {{ DiscussionBoard.errors[5189868].message }}
  • Profile picture of the author Power Solutions
    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.
    Signature
    -=: Internet Marketing News :=------=: Resources I Use :=------=: Prime Ad Network :=------=: ?Profit? :=-
    {{ DiscussionBoard.errors[5196036].message }}
  • Profile picture of the author honeyclarck
    Hello


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

    Try this solution it may be solved your problems.
    {{ DiscussionBoard.errors[5197154].message }}
  • Profile picture of the author kokopelli
    Do as the previous poster said, or use the full path:
    Code:
    <img src="http://yourwebsite.com/images/sample.jpg">
    Signature
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    {{ DiscussionBoard.errors[5232252].message }}

Trending Topics