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;

    }

    }

上一篇:关于DjangoTemplateSyntaxError: Invalid block tag on line 100: ‘***‘, expected ‘endblock‘的这一错误


下一篇:Cannot construct instance of `com.**` (although at least one Creator exists)