0

I am new to programming in PHP. I've created a page in bootstrap, everything worked fine, all icons were there. But after renaming it to test.php (to add some php functions in the future) and moving all the files and folders to Wamp directory (into C:/wamp/www) the images didn't show up. I've googled that for the favicon I need to give absolute path as href="file://C:/wamp/icons/favicon.png" but for some reason this doesn't work for the Bootstrap navbar-brand class. All relevant images are under folder called 'icons', all names are in lower-case. My code:

<body>
   <nav class="navbar navbar-default">
      <div class="container-fluid">
         <div class="navbar-header">
             <a class="navbar-brand" href="test.html"><img alt="Brand" src="icons/main.png"></a>

I've tried to specify the path the same way as for the favicon, but for some reason it doesn't work. I've even tried defining the path as 'http://localhost/icons/main.png' but still nothing. Any ideas please?

Current directory structure looks like this:

C:
|-wamp
|-www
| |-bootstrap
| |-css
| |-test.php
| |-icons
| |-favicon.png
| |-main.png
|-icons
|-favicon.png
|-main.png

gopi
  • 24
  • 1
  • 9
  • 1
    What happens when you visit http://localhost/icons/main.png? – Spencer Rohan Feb 05 '17 at 09:29
  • Okay, that seems to be it. I get forbidden as I don't have permisions to access /icons/main.png. So I suppose it either shouldn't be placed under 'wamp/icons/' or I have to change to access somwhere (in Wamp?). I've tried to copy the icons folder under 'wamp/www/icons', still doesn't work. But strange is, that I can access the favicon. Any ideas? – gopi Feb 05 '17 at 09:34
  • is main.png in wamp/www/icons/main.png? What is the directory for your php page? --This sounds like a directory path issue, not a wamp problem – Spencer Rohan Feb 05 '17 at 09:46
  • Can you post your directory tree? – Spencer Rohan Feb 05 '17 at 09:49
  • One interesting thing - when I go to '127.0.0.1:80' I see all folders and files except the folder with icons (but it exists as sub-directory of 'wamp/www'). Could it have something to do withthe Apache? – gopi Feb 05 '17 at 10:25

2 Answers2

0

So finally, after 2 days of investigation it is solved! The root cause was name of the directory (when changed from 'icons' ->> 'images' it started to be visible on localhost address and it finally works on the php page). The problem is most probably with Apache which was for some reason (clash of names?) ignoring folder called icons.

gopi
  • 24
  • 1
  • 9
0

I believe you are calling your project "bootstrap" according to your directory tree. This means test.php is located within this project folder. If you are on the test.php page. This means that 'http://localhost/icons/main.png' is not the correct url. 'http://localhost/bootstrap/icons/main.png' would be correct.

You've added a new folder titled icons with the images you need to resolve the problem - however this will cause issues if you ever add a second project folder. In the long run, you may have multiple project folders, each with it's own icon sets.

I'm not entirely sure where the html you provided is located, but just watch your directory structure. Also your favicon absolute path would be this - href="file://C:/wamp/bootstrap/icons/favicon.png"

Spencer Rohan
  • 1,759
  • 3
  • 12
  • 23