开发者

Image not showing in src tag

Can anybody tell me how do i give absolute path of the img tag's src attribute?

The following doesn't work

 <img alt="NO IMAGE" src="/home/administrator/tiger-info0[1].gif"/>

I am working On Ubuntu and i am very sure that imag开发者_StackOverflow社区e exists on this path.


This is probably happening because the image is located outside the web server's document root.

Your web server will not be able to serve anything from outside the document root. One possible workaround is to use a scripting language that has access to the file system, and route the images through the script. For example, you may want to check out the following implementation in php:

  • Serving Images Outside Document Root Via PHP

You can also create a symbolic link of /home/administrator/ into the document root:

ln -s /www/yoursite /home/administrator


hmm why don't you copy the image to your web directory and give it the relative path? you server (apache?) may not be able to access the file to serve the browser.


if you are making a local html page you can use that path but if you are creating a website you have to use the absolute path to the document root. And make sure the image path is correct (use firebug)


Give your path correctly with domain or use ../ or ./ is for to represent correct relative path.


You cannot access files that are not in your document root. Get Java application server to not delete your folder. You can probably do this by having one folder into which your users can upload files, and add that folder to your project. You can let users create subfolders inside that main folder, and since the main folder is a part of your project, cleaning the build will not automatically delete it or its subfolders.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜