使用express框架下载文件,但是失败了,直接看代码
express 主页
I love you!
以下是node.js代码
var express = require("express");
var app = express();
app.use(express.static('public'));
app.locals.title = "My app";
app.get("/",function(req,res){
console.log("resquest has been received!");
res.sendFile("public/index.html");
res.end();
})
app.get("/download",function(req,res){
res.download('public/example.jpg','example.jpg',function(err){
if(err)
console.log(err);
else
console.log("download successfully");
});
})
app.listen(3000);
console.log("OK");

求解疑
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
小伙看你根骨奇佳,潜力无限,来学PHP伐。