使用appSettings中的路径显示图像 [英] Display image using path from appSettings
本文介绍了使用appSettings中的路径显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在数据库上传了一张图片。我只保存了数据库中的图像名称和appSettings上保存的路径,例如:
I uploaded an image on database. I saved only name of image on database and the path saved on appSettings like:
<appSettings>
<add key="ItemImagePath" value="C:\Users\USER\Downloads\Mvc4_FileUpload\Mvc4_FileUpload\Content\" />
</appSettings>
图像保存在程序的内容文件夹中。
现在我想使用以下路径显示图像:
the image is saved on the content folder of an program.
Now I want to show the images using the path like:
ConfigurationManager.AppSettings["ItemImagePath"]+@Model.ImageName
我通过以下代码显示图像:
I am showing the image by the code like:
var imagePath = System.Configuration.ConfigurationManager.AppSettings["ItemImagePath"]+@Model.ImageName;
<img src=@imagePath alt="Sample Image" width="300px" />
但它显示无法加载图片!!!
请你帮我这么做。
But it shows that "could not load image"!!!
Would you please help me to do that.
推荐答案
这篇关于使用appSettings中的路径显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文