var express=require("express")
var app=express();
var fs = require('fs');
var path=require("path");
app.get("/upload",function(req,res){
var filePath = path.join(__dirname, './');
console.log(filePath)
fs.readFile(filePath+"images/2010191.png", function(err, data){
res.set({
'Content-Type': 'application/octet-stream', //告诉浏览器这是一个二进制文件
'Content-Disposition': 'attachment; filename=upload.png' //告诉浏览器这是一个附件要下载是png图片
});
res.end(data)
})
})
app.listen(3000,function(){
console.log("server is running")
})
发布者:admin,转转请注明出处:http://www.yc00.com/web/1742571310a4460462.html
评论列表(0条)