Adding Image in html

陌路散爱 提交于 2021-02-05 11:45:30

问题


I cannot seem to add an image in html. I'm using ASP.net MVC 3. My image, named KeyLargoPic, is located on a flash drive in the folder X:\Project\Project\Photos\Key Largo, and it appears to be a JPEG. The code is as follows:

<td><img src="X:\Project\Project\Photos\Key Largo\KeyLargoPic.jpg" alt="IMAGE" /></td>

Every time the page loads, it shows the box with "IMAGE" inside. Does anyone know what I'm doing wrong?


回答1:


Add the image to your project, probably in the content directory, by right clicking the directory and clicking "Add" then "Existing Item", browse to your jpeg and click "Add". With your image now part of the project you can add it to the webpage like so:

<td><img src="@Url.Content("~/Content/KeyLargoPic.jpg")" alt="IMAGE"></td>



回答2:


Upload the image to your web server and reference via web path from your project. The web server can't read from your usb drive.




回答3:


Try to mount a virtual directory in IIS pointing to X:\Project[...] so you will be able to access your ressources with a relative address



来源:https://stackoverflow.com/questions/17938021/adding-image-in-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!