Jump to content

Images in include files


carlg

Recommended Posts

I have an include file which is in my main directory.

 

I have a file in a sub dir that includes this file.

 

so I have

 

ini_set (include_path, "../");
include ("myfile.php");

 

myfile.php lives in ../ which is the parent dir

 

myfile.php includes some <img> tags, but th images are not being found since they are in another dir

 

How do I fix this?

 

Thanks

 

 

 

Link to comment
Share on other sites

OK, maybe I need to word this better.

 

My directory structure looks something like this

 

$DOCROOT/includes

$DOCROOT/myfiles

 

I made the banner for my site and called it banner.php.  It resides in the includes subdirectory.  banner.php has some img tags within the code and I include banner.php in all of my php pages.

 

I have a file in myfiles called mypage.php and it includes banner.php.

 

All of the text from banner.php is showing up perfectly fine but all of the images are not there.  If I call up a file that is in the DOCROOT that has banner.php included, the images show up fine.

 

Hope I'm more clear

 

thanks

 

carl

 

Link to comment
Share on other sites

Can you use an absolute path to the images? If you're using relative URLs, that might make things get hairy.

 

You could also use absolute paths relative to your docroot. Call the image like so: <img src="/images/whatever.png">

 

This will look in docroot/images/ for the file. Make sense?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.