Created
December 7, 2015 08:35
-
-
Save anehkumar/5cb6d6965e250529dcb3 to your computer and use it in GitHub Desktop.
Routes file entry to view image capture page and handle image upload.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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