📜  如何从 dir nodejs 加载图像 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:06.092000             🧑  作者: Mango

代码示例1
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.
  });
}