//顯示照片,利用 Pid 到資料庫捉出圖檔 public FileResult ShowPhoto(int id) { ProductEntity pe = new ProductEntity(); byte[] content = pe.GetPicture(id.ToString()); return(File(content, "image/jepg")); }
//顯示照片,利用 Pid 到資料庫捉出圖檔 public string ShowPhoto(int id) { ProductEntity pe = new ProductEntity(); byte[] data = pe.GetPicture(id.ToString()); string imgSrc = null; if (data != null) { using (MemoryStream ms = new MemoryStream()) { ms.Write(data, 0, data.Length); string imgBase64 = Convert.ToBase64String(ms.ToArray()); imgSrc = string.Format("data:image/jpg;base64,{0}", imgBase64); } } return(imgSrc); // return File(content, "image/jpg"); }