Link to home
Start Free TrialLog in
Avatar of breeze351
breeze351

asked on

Syntax for opening an image in PHP

I'm trying to display a gif for a menu.  This is the same type of problem that I had with the new server.  This code worked on the old one.

<a href="./index.php" class="nof-navButtonAnchor"><img id="NavigationButton1" name="NavigationButton1" height="21" width="137" src="../Autogen/Menu_Hhighlighted_1.gif" border="0" alt="Menu" title="Menu"/></a>

If I copy the file "Menu_Hhilghted_1.gif" to the root and mod the code to rellect that it works.

The directory structure is:
Lansco
  -->Autogen
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

I think this is an HTML file path issue, not a PHP problem.

Looks like a different directory structure from the old server.  One way to fix this problem is to use fully qualified absolute URLs.    They don't break.  Another is to analyze the new directory structure, find out where image resources are located (relative to the URL of the document that is having the problem) and write a relative link that works for the new directory structure.

You can use a slash as the first character of the link, and it will be resolved relative to the web root of the host.  So if you know your directory structure that might be an easy way to find the image.
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ludofulop
ludofulop

where in the directory structure is placed the (php/html) file that contains that html code ? Maybe src="./Autogen/Menu_Hhighlighted_1.gif"  should do it ?
If I was me, I'd do it this way.  The single '/' indicates that the file and directory are relative to the root.  I figure if I have to use all those dots, I'm doing something wrong.
<a href="/index.php" class="nof-navButtonAnchor"><img id="NavigationButton1" name="NavigationButton1" height="21" width="137" src="/Autogen/Menu_Hhighlighted_1.gif" border="0" alt="Menu" title="Menu"/></a>

Open in new window

Avatar of breeze351

ASKER

That was it. The last site had a root where the subdirectory was.  I have to clean up this code.
Thanks
Glenn
This hint can make your life easier :-)

You can use a slash as the first character of the link, and it will be resolved relative to the web root of the host.  So if you know your directory structure that might be an easy way to find the image.