简体   繁体   中英

how do I fix the HTML img tag to display an image

I'm trying to display to the enduser an image, but this tag wouldn't work, how can I fix it please ?

<img src="file:///E:/images/avatars/21082013184506Id.png" height=70 width=70 />

Thanks in advance.

您的文件寻址是绝对的,它仅在该映像存在于该目录中的计算机上起作用,您应该使用隐式寻址。

  • End users will not have access to your hard disk.
  • Some browsers block access to images on file:// URIs from pages loaded over HTTP.

Use an HTTP URI for your src.

The image in src="" is on your own hard disk.

Upload the image to a image-uploader like imageshack or a webserver.

Put in src="" the correct path to the file.

as John asked in the comment, the image will only appear when the source path specified is available to user viewing the html.

The attribute src="file:///E:/images/avatars/21082013184506Id.png" means the user must have access to E: drive.

If you want this to work online on the internet, upload the image with your page and specify path to it eg in case it is in same folder as you html

src="21082013184506Id.png"

if it is in images/avatars subfolders

src="images/avatars/21082013184506Id.png"

I would also recommend quoting the width/height attributes ie width="70" height="70", or even better set those values via CSS, but that a different topic :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM