Forum Moderators: coopster

Message Too Old, No Replies

./ include file not showing images

         

adamnichols45

9:55 am on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



folder system as follows :-

*** WWW FOLDER ***

index.php
images folder
articles folder

------------------------
*** articles folder ***

aboutme.php

^^^^ this include an include to index.php and i use the following code.

<?php include "../index.php"?>

but when index is displayed it does not show the images!

Any easy work arounds please

i dont want to have to have every image as
<img src="www.example.com/images/header.gif"

Birdman

10:13 am on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just use the full path without the domain:

<img src="/images/header.gif">

... and they will resolve froom any folder you call them from.

Habtom

10:24 am on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am not sure exactly what is happening on your case. But it could be that, if you have to include a page into a number of pages in different folders, the image link might not work at some of them. What i suggest you do is trying to go up as much as you can and mention the path. If you can go up three folders ../../../images/image1.jpg

This way you can avoid typing the whole URL.

Habtom

adamnichols45

10:29 am on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



thats still does not work

if i go to the webspage and view source i get the following

<img src="/images/header.gif">

adamnichols45

10:32 am on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



birdman that did not work

yes habtop your right there with the images folder being called from different folders

What did work was <img src="../images/header.gif">

but then when i go back to index.php the images do not show.

as they would be linked from header.php as ../

so just to clear up in the header file in the root folder i want to link to images folder.

but from index.php ../ will not exist sorry if thats slightly confusing

adamnichols45

10:35 am on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What does work is [localhost...]

but is this good practice? i dont want to reveal to much to people looking at my source code on the internet.

Also when it comes to uploading, hundreds of links will need changing although i should be able to use my software to REPLACE "" with ""

Habtom

12:19 pm on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try <img src="../../images/header.gif">

jatar_k

5:10 pm on Apr 12, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



it is a path problem for sure

using the absolute path from the web root should work fine

/images/imagename.gif

this means the images folder is located in the webroot and can be referenced as such from anywhere within the site.

you can test this path by pasting it into the location bar and adding just the domain in fromt, like so

www.example.com/images/imagename.gif

if the above doesn't work then you have the wrong path.

when you use ../ and you include that file from various places on your site it will not work as the path changes depending on where it is included from.