Tuesday, 2 May 2017

[Halp! NodeJS + SocketIO] I am trying to take an image converted to base64 and emit to my server for saving, but all the server receives is null.

This is client-side.function sendNewImg(){ var img = imageTo64(); socket.emit('newImg', img); } function imageTo64(){ var imageAs64; var file = document.getElementById("imgFile").files[0]; var reader = new FileReader(); reader.addEventListener("loadend", function () { imageAs64 = reader.result; document.getElementById('removeThis').innerHTML = imageAs64; }, false); reader.readAsDataURL(file); return imageAs64; } Now I know by my 'removeThis' p that I am getting the base64 encoding, but server-side all I receive is 'null'. :(HALP I don't know what to do. All I know is the base64 string is enormous enough to cause lag when viewed in browser. Also, image data: Original size = 597kb, Encoded size = 797kb. Strange to me that the size increases so much but idk. Anyway could the size be the problem? I'm considering breaking the string down and sending through many emits but I figured I'd come here in hopes of something easier...

Submitted May 02, 2017 at 08:33PM by JonFrost

No comments:

Post a Comment