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")
})
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")
})