Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple app
$("#send").click(function(e) {
// convert canvas to data url
var img = canvas.toDataURL();
// make request to server
$.post("/", {img: img, n: n}, function() {
// when request is finished, redirect to homepage
return false;
});'/', function(req, res) {
// extract arguments from request
var img = req.body.img
, n = req.body.n;
// extract image data from img
var data = img.replace(/^data:image\/\w+;base64,/, "");
// write image to a binary file
var buf = new Buffer(data, 'base64');
var f = "numbers/" + uuid.v1() + "_digit_" + n + ".png";
fs.writeFile(f, buf);
// redirect the user to the homepage (gives them a new number to input)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.