美文网首页
下载文件中文名乱码

下载文件中文名乱码

作者: 胖子罗 | 来源:发表于2019-07-20 14:12 被阅读0次

原来NodeJS代码:

const header = { 'Content-Disposition': 'attachment;filename=' + encodeURIComponent(fileName)+'.'+ format}

问题:下载的文件中文名在chrome浏览器正常,在firefox浏览器下不正常
修改代码如下:

const utf8str = 'UTF-8'
const header = { 'Content-Disposition': `attachment;filename*=${utf8str}''` + encodeURIComponent(fileName)+'.'+ format}

参考:
https://blog.csdn.net/liuyaqi1993/article/details/78275396

相关文章

网友评论

      本文标题:下载文件中文名乱码

      本文链接:https://www.haomeiwen.com/subject/jcxulctx.html