/** * Created by wenhui on 2017/2/26. * 读取图片在浏览器显示 */ var http = require('http'); var fs = require('fs'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type':'image/jpeg','chartset':'utf-8'}); fs.readFile('./img/tree.jpg', 'binary', function (err, file) { if(err){ throw err; return; }else{ console.log('输出文件'); res.write(file,'binary'); res.end(); } }); }).listen(3000);
读取图片在浏览器显示
最新推荐文章于 2021-01-27 10:03:24 发布