set header不适用于nodejs中的文件名 [英] set header not working for filename in nodejs
本文介绍了set header不适用于nodejs中的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在下载
下面更改文件名称
res.setHeader('Content-Disposition','attachment; filename ='+ fileName +');
res.setHeader('Content-Type','image / jpg');
res.download(filepath);
任何帮助都会赞赏,请建议
解决方案
res.get('/ download',function(req,res ){
res.download(__ dirname +'jsonFile.json','jsonFile.json');
});
all uploded file name are encrypted , so when i want to download those file i am changing file name with there actual file name which are saved in data base, below code should work but not in my case, how to change file name while downloading
below is my code for it
res.setHeader('Content-Disposition', 'attachment;filename="' + fileName + '"');
res.setHeader('Content-Type', 'image/jpg' );
res.download(filepath);
any help will b appreciated , please suggest
解决方案
res.download() not working in my case
res.get('/download', function(req, res) {
res.download(__dirname + 'jsonFile.json', 'jsonFile.json');
});
这篇关于set header不适用于nodejs中的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文