Answers for "how to load image from dir nodejs"

0

how to load image from dir nodejs

var fs = require('fs');
function(req,res){
  fs.readFile('image.jpg', function(err, data) {
    if (err) throw err; // Fail if the file can't be read.
      res.writeHead(200, {'Content-Type': 'image/jpeg'});
      res.end(data); // Send the file data to the browser.
  });
}
Posted by: Guest on April-03-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language