Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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.
  });
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #load #image #dir #nodejs
ADD COMMENT
Topic
Name
7+9 =