linkyndy
linkyndy

Reputation: 17928

Can't view image from webroot in CakePHP

I am trying to display an image from the /webroot/img/ folder using the following CSS syntax: .template-mainbg{background:#B8D9EA url('../img/bg_top.png') repeat-x left top;}

The image never loads and if I try http://site.com/img/bg_top.png it gives me a Missing Img controller error.

This very wierd since the default Cake icon loads perfectly. Both from CSS and direct link.

What could be the problem?

Thank you!

EDIT I solved this problem. Unfortunately I spent 2 hours to figure out that Dreamweaver didn't sync the image with the remote server. Thank you anyway for all your help!

Upvotes: 0

Views: 2992

Answers (1)

Ross
Ross

Reputation: 17987

paths are relative to the CSS document, so it depends where the CSS file is being served from.

In the above example, ../img/bg_top.png your CSS file would need to be in the site root I believe.

The image never loads and if I try http://site.com/img/bg_top.png it gives me a Missing Img controller error.

my understanding is that you can't access anything from "above" the webroot from a browser, hence the message.

Upvotes: 1

Related Questions