Jump to content

Cannot get image to display


crmamx

Recommended Posts

For your index.php page in the prototype folder to display an image in prototype/content/ you would need to use -

 

<img src="content/flag_usa.gif" width="84" height="63" alt="usa flag image" />

 

Edit: Alternatively, you can use a domain_root relative URL -

 

<img src="/prototype/content/flag_usa.gif" />

Link to comment
Share on other sites

Thank you so much. It works. This has been driving me crazy.

 

Could you please explain it to me.

 

File structure:

                          prototype----------index/php

                              content---------maincontent.php, flag_usa.gif

                                    images

 

Why is the reference from index.php and not maincontent.php? It seems I am calling it from maincontent.php.

 

In my hundreds of other programs using just plain html if the program and image are in the same file, then I was using the correct src.

 

Don't know if I will make it thru this redesign or not... :'(

Link to comment
Share on other sites

I going to assume that you are including the maincontent.php file into index.php?

 

That includes the php code that is in maincontent.php ('content'  just happens to be the path to where php can find the maincontent.php file at) into index.php. When the code is finally executed, the code that was included from maincontent.php is part of index.php and is being executed as part of index.php.

 

Looking at this a slightly different way. The browser requested index.php. It is also the browser that requests the image in the src="..." attribute. The browser has no idea that maincontent.php even exits because the browser only sees the HTML that your index.php file outputs. Any relative URL's in an <img> tag are relative to the page they are on, in this case index.php.

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.