我不知道我该怎么做。这是我搜索图像时的代码:
public ActionResult SearchImage() {
var path = @"\\jesus-pc\Frontera\IMAGENES\SINGNOS DISTINTIVOS\0\80HP23891268272.TIF";
FileStream stream = new FileStream(path,FileMode.Open,FileAccess.Read);
byte[] data = new byte[(int)stream.Length];
stream.Read(data,0, data.Length);
return Json(new { base64image = Convert.ToBase64String(data) }, JsonRequestBehavior.AllowGet);
}
我通过ajax做到这一点:
$(".doc").dblclick(function () {
$.ajax({
url: "mainpage/SearchImage",
contentType: 'application/json',
dataType: "json",
type: "get",
success: function (data) {
ModalWindow.open();
document.getElementById("img_1").src =
"data:image/jpeg;base64"+data.base64image;
}
})
但这是我在浏览器中得到的:
{ base64image:“SUkqAEgAAABXQU5HIFRJRkYgAQAwAAAAVGl0bGU6AEF1dGhvcjoAU3ViamVjdDoAS2V5d29yZHM6AENvbW1lbnRzOgAAAAAAEgD+AAQAAQ...AAFXEAAAA==”