如何显示保存在路径MVC中的图像 [英] How to display image saved in path MVC
本文介绍了如何显示保存在路径MVC中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在路径中保存了图像并使用mvc5将名称(GUID)传递给sql数据库,当我再次查询加载数据时,我可以获取图像的名称,如何通过此名称从位置获取图像
谢谢!
我的尝试:
只读数据库中的图像名称,
I have saved images in a path and pass the Name(GUID) to sql database using mvc5, when i query for load data again, i can get the name of image, how to get image from location by this name
Thank You !
What I have tried:
just only read image name from database ,
推荐答案
你好,
如果将文件保存在客户端服务器路径上。然后使用下面的代码:
var fileName =从带扩展名的DB获取文件名。
Hello,
If you save your file on client server path. Then use the below code:
var fileName = "Get file name from DB with extension".
var pathFile = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~/Images/"), fileName);
谢谢
Ajay
Thanks
Ajay
这篇关于如何显示保存在路径MVC中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文