I am writing a web based app that lets the user crop an image then save it to his/her computer then show it in the html. I am successful on cropping the image and saving it into the computer however I am having problems displaying it in the html. It does not show anything.
Here is the code in my controller that saves the cropped image:
string base64 = Request.Form["imgCropped"];
byte[] bytes = Convert.FromBase64String(base64.Split(',')[1]);
using (FileStream stream = new FileStream(@"D:\CroppedPhotos\myPhoto.jpg", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
{
using (BinaryWriter bw = new BinaryWriter(stream))
{
bw.Write(bytes);
bw.Close();
}
stream.Close();
}
Note: the image is from an html canvas. I put value in imgCropped by using the canvas.toDataURL
Here is the code in my html that should show the cropped image:
<img src="D:\CroppedPhotos\myPhoto.jpg" width="424" height="476">