以base64格式返回圖像,我有以下的代碼來裁剪圖像:無法加載資源:服務器500(內部服務器錯誤)的狀態迴應,同時從控制器
$.ajax({
type: "POST",
url: root("CropController/CropImage"),
data: {
imagePath: imagesrc,
cropPointX: parseInt(PointX),
cropPointY: parseInt(PointY),
imageCropWidth: parseInt(CropWidth),
imageCropHeight: parseInt(CropHeight)
}
}).done(function (dt) {
alert(dt.photo);
});
而控制器代碼是:
public JsonResult CropImage(string imagePath, int? cropPointX, int? cropPointY, int? imageCropWidth, int? imageCropHeight)
{
string output = imagePath.Substring(imagePath.IndexOf(',') + 1);
byte[] imageBytes = Convert.FromBase64String(output);
//croppedImage will have the cropped part of the image.
byte[] croppedImage = ImageCroping.CropImage(imageBytes, cropPointX.Value, cropPointY.Value, imageCropWidth.Value, imageCropHeight.Value);
string photo = "data:image/jpeg;base64," + Convert.ToBase64String(croppedImage);
return Json(new { photoPath = photo }, JsonRequestBehavior.AllowGet);
}
如果種植面積較小,則在完成功能警報將被調用,但是當種植面積大,做功能不會觸發它拋出的錯誤。任何人都可以幫助我這個。在此先感謝
你見過[這](http://stackoverflow.com/a/12278956/1429080 )回答? – user1429080