开发者

can't show image via <img> tag

I am trying to show an image by doing the following:

<img class="header" src="banner.png"></img&g开发者_C百科t;

banner.png is located in the same folder as my .php file. Why can't it find it when I trace it in firebug?

Solution::

What happened was I copied the image via FTP, and the permission was not set to read, doing a chmod solves the issue.


Aside from anything else, an img tag should close itself:

<img class="header" src="banner.png" />

Other potential, though unlikely, causes include:

  • Is banner definitely a .png file?
  • Is the filename all lowercase? Banner.png is different to banner.png

Also, credits to animuson in comments: If this script is being included (if you don't know what that is, ignore this possibility), then the path should be relative to the including script, not the included script.


Are you working from a web server (like Apache or lighttpd or Mongrel) or directly from files (you will see file:// in your browser bar)?

If your website is hosted on a web server, make sure the file permissions on the banner.png file are set to allow the web server to access them - otherwise it won't be able to serve the file. Then for all intents and purposes the file doesn't exit. Changing that depends on your host server's operating system.

Shot in the dark here for what you have - on Linux and Max OSX, you can use "chmod 664 banner.png" when in your directory. That setting should be sufficient.

If you are working from files - I think something else is off! Check the permissions anyway.

UPDATE: Turns out this was the issue :)


Only thing I see wrong is the fact that you are using a closing tag. img tags are self closing always

<img class="header" src="banner.png" />


perhaps its a permission thing go in terminal

sudo su
cd /Library/WebServer/Document
chmod 755 the image file name

this will probably fix it if your problem is localhost

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜