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
https://forums.phpfreaks.com/topic/86818-images-in-include-files/
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

 

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.