I am trying to upload image and want to save in folder. For this I am doing
I am using image data url of uploaded image and passing it through ajax via form to .ashx page (asp.net c#). I have succesfully uploaded image and send to .ashx page. But on ashx page I am unable to extract image and save it.
My Ajax Code that send Image as image dataurl to ashx page.
var mgsrc = document.getElementById('result_image').value;
var fd = new FormData();
fd.append('image', mgsrc );
$.ajax({
url: 'http://localhost:53582/Hulk%20Man%20Vers/Handler.ashx',
data: fd,
processData: false,
contentType: false,
type: 'POST',
success: function(data){
alert(data);
}
});
}
.ashx page Code that Receive form.
public void ProcessRequest (HttpContext context)
{
string e = context.Request.Form.ToString();
var imageBase64String = context.Request.Form["image"];
byte[] encodedBytes = Encoding.UTF8.GetBytes(imageBase64String);
//now what to write to get image and save it in folder
}
Somebody , Please let me know how I can save the image. I will be very greatefull . Trying the code from last 5 days.