//将虚拟路径转化为文件的路径然后最后转化为文件流

public ActionResult SaveImage(string path)
{
var url =System.Web.HttpContext.Current.Request.PhysicalApplicationPath + path;

FileStream fs = new FileStream(url, FileMode.Open, FileAccess.Read); //将图片以文件流的形式进行保存
BinaryReader br = new BinaryReader(fs);
byte[] imgBytesIn = br.ReadBytes((int)fs.Length); //将流读入到字节数组中
Encoding myEncoding = Encoding.GetEncoding("utf-8");
string stImageByte = Convert.ToBase64String(imgBytesIn);

return Json(stImageByte);
}

 

相关文章:

  • 2022-12-23
  • 2021-10-19
  • 2022-02-19
  • 2022-12-23
  • 2022-12-23
  • 2021-07-05
  • 2022-12-23
猜你喜欢
  • 2021-04-04
  • 2022-12-23
  • 2021-12-13
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案