我正在使用MVC。我需要上传图像并将其显示在同一页面中。 我已上传图像并将图像存储在本地文件夹中。 如何使用mvc
显示本地文件夹文件中的图像答案 0 :(得分:2)
最好的方法是创建一个操作,从文件夹加载文件并将其返回。
使用FileContentResult
:
public FileContentResult Display(string filename) {
byte[] byteArray = GetImageFromDisk(filename);
return new FileContentResult(byteArray, "image/jpeg");
}
以上是一个非常简单的示例,可以帮助您前进。