如何从本地驱动器显示图像 [英] how to display image from local drive

查看:72
本文介绍了如何从本地驱动器显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string ImageFile = itm.ProductImageURL.ToString();



// ImageFile vaue是C:\ Users \Public \Pictures \Sample Pictures\logo1.png

//这是一个本地路径,我想显示本地驱动器中的图像,这个图像不在我正在运行的项目中。只有路径在数据库中。



string ImageFile = itm.ProductImageURL.ToString();

//ImageFile vaue is "C:\Users\Public\Pictures\Sample Pictures\logo1.png"
//this is a local path , i want to show an image from local drive ,this image not in my running project. only path is in database.

<a href="/ProductList/ProductDetails/@itm.Id">
                            <img src="@ImageFile " class="img-responsive" alt="Berry Lace Dress"></a>

推荐答案

错误,并非每个人都有C盘中的图像。但是,从本地存储运行图像没有任何问题,您只需要写入正确的图像位置。



试试这段代码,< br $> b $ b

Wrong, not every one would have the image in their C drive. However, running an image from local storage doesn't have any trouble, you just need to write the write the correct location for the image.

Try this code,

<img src="@ImageFile " class="img-responsive" alt="Berry Lace Dress">
</img>





在ASP.NET中,您通过在变量名称前添加前缀来使用服务器端变量在HTML标记中使用 @


这篇关于如何从本地驱动器显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆