Jump to content

include()'ed html file not displaying img's


cedricganon

Recommended Posts

Hello

 

So in my index.php code i include('somefile.html');. In the html file itself there is an <img src="/images/picture.jpg">. When looking at index.php on a browser, the html looks fine everything loaded fine except for the <img> There is a little broken image link displayed on the page. i checked through the browser if i mistyped the img src link but somefile.html in the browser displays the image fine. But if i try to display the img in the html file through the php file, its a broken link. Any reason why this is happening? Am I missing something here? Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/251759-includeed-html-file-not-displaying-imgs/
Share on other sites

yes it is. to give you an idea of the structure its something like this:

 

index.php: root folder

 

somefile.html: /dir1/dir2/somefile.html

picture.jpg:  /dir1/dir2/images/picture.jpg

 

the images folder is located in the same folder as somefile.html. I've tried using a path relative to the root folder for the image ie:

<img src='/dir1/dir2/images/picture.jpg'>    as opposed to a path relative to somefile.html:    <img src='/images/picture.jpg'>

neither presents an image

 

 

A leading slash on a link/URL refers to the root of the domain (i.e. a domain relative link/URL.) All the URL's you have shown in your post are trying to find the file starting at your domain root -

 

http://yourdomain.com/images/picture.jpg

http://yourdomain.com/dir1/dir2/images/picture.jpg

 

Relative URL's either start with a dot or double-dot or are just the filename.

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.