For the past couple of days I have been looking for a way to send a string from the client to Node, with no luck.
At the moment, I have a form with a dozen inputs and an image cropping tool (fengyuanchen/cropper) that will have the user upload a photo, edit (resize, crop, etc...) and save the dataURL (data:image/png;base64,iVBORw0KGg[...]) in a variable. The form inputs I don't have an issue with, they're updating in the database just fine. I'm having issues passing the variable containing the dataURL.
Ideally, I would like to have just one form that the user submits that will 1) update the database with the input fields and 2) pass the canvas dataURL to node, decode, save the image in the server, and add an entry in MySQL. Either that or use AJAX to submit the cropped photo separately without erasing modifications to the input fields.
From SO question: Save canvas data to file. The chosen answer assumes "you already know how to POST that string from the browser to your Nodejs server." That's the part I'm stuck on.
I've read about possibly using: 1) hidden form fields - would this be possible/performant? 2) Node's module loader 3) Require.js 4) socket.emit('image', dataURL)
I've re-sized the image to 1024x360 so as to keep the dataURL as short as possible with a decently looking photo until I find a better solution. Still, these dataURLs end up quite large (I've seen some as large as 700,000 characters). Would I be able to send the data through JSON?
Any help would be greatly appreciated.