How to display image in html image tag - node.js [on hold]
- by ykel
I use the following code to store image to file system and to retrieve the image, I would like to display the retrieved image on html image tag, hower the image is rendered on the response page but not on the html image tag.
here is my html image tag:
<img src="/show">
THIS CODE RETREIVES THE IMAGE:
app.get('/show', function (req, res) {
var FilePath=__dirname+"/uploads/3562_564927103528411_1723183324_n.jpg";
fs.readFile(FilePath,function(err,data){
if(err)throw err;
console.log(data);
res.writeHead(200, {'Content-Type': 'image/jpeg'});
res.end(data); // Send the file data to the browser.
})
});