Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Can't display images
January 21, 2010, 8:32 pm
rate this thread
I am preety new to web development.
I must be missing something very basic here.
I developed a php file named Register.php.
I put couple of images in it.
I use apache tomcat 6.0
I loaded the file by typing http://localhost:8080/forphp/Register.php
on the address bar in IE8.
The images are not loaded.
The images properties shows that they refer to http://localhost:8080/<image
file name> as the image is at the same folder like Register.php
The folder forphp is under webaps directory which is in tomcat
The tomcat service is up.
Any help will be appreciated.
Re: Can't display images
On Thu, 21 Jan 2010 12:32:34 -0800 (PST), dushkin put finger to
keyboard and typed:
There's your problem, then. You've given the images an absolute
instead of relative path, and they're being loaded (or, rather,
failing to load) from the root directory.
Your HTML source looks something like this:
whereas it should look like this:
The first of those (note the absence of the leading /) makes the image
location relative to the file calling it rather than the root
directory, while the second uses an absolute path (with a leading /)
and includes the directory where the images are located.