MVC 读取图片

/// <summary>
/// 获取上传的图片
/// </summary>  
public FileResult GetImages(string PhotoPath)
{

    var filename = PhotoPath.ImageUploadPath();//获取图片路径

    if (!string.IsNullOrEmpty(filename))

      {

        FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);

        int length = (int)fs.Length;

        byte[] image = new byte[length];

        fs.Read(image, 0, length);

        fs.Close();

        return new FileContentResult(image, "image/jpeg");

      }

      else

      {

        return null;

    }

    }

原文地址:https://www.cnblogs.com/jerrywublogs/p/4599350.html