hello
I am using this code to send image data to server.
however it works for me only with amll png and not with jpg or bigger images.
what is the problem ?
reader = new FileReader();
reader.onload = function (e) {
document.getElementById("blah").src = e.target.result;
pp = e.target.result;
}
reader.readAsDataURL(file);
fileName = (file.name).slice(-3);
}
function UploadPic() {
// generate the image data
var Pic = pp.replace(/^data:image\/(png|jpg);base64,/, "")
// Sending the image data to Server
$.ajax({
type: 'POST',
url: 'Save_Picture.aspx/UploadPic',
data: '{ "imageData" : "' + Pic + '", "imageName" : "' + fileName + '" }',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (msg) {
alert("Done, Picture Uploaded.");
}
});
}
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
shahbaz ahamedPosted Apr 12, 2015, 5:52 AM
Vishwakant TripathiPosted Apr 11, 2015, 3:59 PM
If you have issue with image size exceeds limit, so you can paste below lines in web.config and give a try to upload a jpg or max size file.
If it does not help you, let me know what you are getting exactly error.