Skip to content

Instantly share code, notes, and snippets.

@anehkumar
Created December 7, 2015 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anehkumar/5cb6d6965e250529dcb3 to your computer and use it in GitHub Desktop.
Save anehkumar/5cb6d6965e250529dcb3 to your computer and use it in GitHub Desktop.
Routes file entry to view image capture page and handle image upload.
router.get('/captureImage', function(req, res, next) {
res.render('captureImage', { title: 'Capture Image and upload' });
});
router.post('/captureImage', function(req, res, next) {
//console.log("FormData "+ req.body.base64);
var base64Data = req.body.base64.replace(/^data:image\/png;base64,/, "");
fs.writeFile("uploads/out.png", base64Data, 'base64', function(err) {
if(err){
console.log(err);
}else{
res.send(JSON.stringify({'status': 1, 'msg': 'Image Uploaded'}));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment