follow us on google+ follow us feedburner


Go to Topic: PreviousNext
Go to: Message ListNew TopicSearchLog InPrint View

images not loading in page. They load individually though

Posted by: erasmose
October 03, 2012 12:52PM
I'm a total newbie to Apache.
I have added JPG and GIF MIME Types to the Apache config but it still doesn't load the images.
It must be very simple to solve but somehow I don't seem to find the answer...
Options: ReplyQuote
Posted by: _Thierry_
October 04, 2012 11:56AM
in html/pages the path of images must be relative to apache document root folder:

in local: www/img/myimage.png
HTML: src=img/myimage.png
Options: ReplyQuote
Posted by: erasmose
October 04, 2012 11:48PM
Hi Thierry_
Yes it is relative. It works fine when I run the page on IIS.
I tested it with no PHP code so I assume there is something wrong in Apache settings.
It doesn't load gif, jpg, swf in my page.
Basically if I put the image file address in browser it works:
but when I load the page that has this image, it can't load the image.
And I have set the MIME types to load these stuff.
Options: ReplyQuote
Posted by: erasmose
October 04, 2012 11:50PM
I'm on win 7.
I tried other versions of easy PHP and it does the same thing.
Options: ReplyQuote
Posted by: erasmose
October 04, 2012 11:52PM
Also for some images it fives a 403 error when I put the image's address in the browser:
Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

If you think this is a server error, please contact the webmaster.

Error 403
Options: ReplyQuote
Posted by: erasmose
October 05, 2012 09:23AM
Ok, I did some more tests.
If I put the files in an EasyPHP folder like: C:\Program Files (x86)\EasyPHP-12.1\home it works!!
So there is something in the settings of the files or folders that is missing?
Does every folder need a .htaccess file? Removing that file from the EasyPHP-12.1\home made it fail. but adding the same .htaccess to www folder didn't make it work
Options: ReplyQuote
Posted by: erasmose
October 06, 2012 01:02AM
I just made it work.
It still sometimes needs clicking on a link 2 times to work.
Options: ReplyQuote
Posted by: robmcl
November 12, 2012 04:53AM
What was the solution to 'make it work'
The apache setting setting for docs is clearly pointing to the www folder (eg ${path}/www) but I have several sites each in a subfolder (eg. www/siteA and www/siteB)

In the reply from Thierry on Oct 4, its clear that the ref must be relative...
" in local: www/img/myimage.png
HTML: src=img/myimage.png "

but I dont really want to write src=www/img/myimage.png throughout my code, only to need to revise every path when I'm ready to move the site to live hosting (where the www will be invalid).

Am I missing something here? (I'm asking honestly and not being sarcastic). Do others simply write an IF stmt to test if the site is local or live anf chabge the path accordingly? and if so, how exactly are you coding that?

Options: ReplyQuote
Posted by: Russell
November 12, 2012 08:22PM
Relative URLs mean you don't have to change them when you move the site over to production, they're relative to the root directory of the website.

You wouldn't write src=www/img/myimage.png as the webserver already know you are in www, you just write src=img/myimgae.png as Theirry said.

The other type of URL which do need changing when moving servers is called absolute. That would look like src='http:/'.
Options: ReplyQuote
Posted by: robmcl
November 20, 2012 05:08PM
Found the solution, so I'm posting here fyi in case someone else makes the same mistake <grin> Here's an example...
Document root = C:\EasyPHP\www
Site folder = C:\EasyPHP\www\siteA
Images folder = C:\EasyPHP\www\siteA\images
Site loads fine at []

code = src='/images/pic.png' is looking for the image in [] = obviously not found because siteA is not in the path

change the code to src='images/pic.png' -or- src='./images/pic.png'... the path is now [] = BTW this is a Wordpress site, but the path now includes that WP page name

change the code to src='../images/pic.png' and it works... I needed to go one level higher to get past the WP page name. I had also thought this would not work when moved to the webhost since an add'l level upward in the path didn't seem correct...but it does work fine.

Options: ReplyQuote

Go to: Message ListSearchLog In
Your Name: 
Your Email: 
Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.