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
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

 

 

Link to comment
Share on other sites

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.

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.