TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
gavriel ankri
NA
39
48.5k
send image to data server
Apr 11 2015 4:31 AM
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.");
}
});
}
Reply
Answers (
2
)
Hide the browser history
How to remove cookies which was set by ajax response