//將虛擬路徑轉化爲文件的路徑而後最後轉化爲文件流數組
public ActionResult SaveImage(string path)
{
var url =System.Web.HttpContext.Current.Request.PhysicalApplicationPath + path;url
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);spa
return Json(stImageByte);
}圖片