[英]Node.js problem with downloading file - filename
I have a problem, I made a Node.js server, and when I wanted to download a file from it, the file at the end of the name gets _}
.我有一个问题,我做了一个 Node.js 服务器,当我想从中下载文件时,名称末尾的文件会得到
_}
。 I don't know why is that.我不知道为什么会这样。 Example
img.jpg_}
示例
img.jpg_}
else if(req.url == '/download'){
var files = fs.createReadStream("img.jpg");
res.writeHead(200, {'Content-disposition': 'attachment; filename=img.jpg"}'});
files.pipe(res);
Hey your quotes are misplaced.嘿,你的报价放错了地方。 use the following code it will work.
使用以下代码它将起作用。
else if(req.url == '/download'){
var files = fs.createReadStream("img.jpg");
res.writeHead(200, {'Content-disposition': 'attachment; filename = img.jpg'});
files.pipe(res);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.