**一开始的写法:** `c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", url.QueryEscape(showFileName)))` 能够兼容大多数浏览器,部分浏览器文件名还是会乱码,比如iPhone的Safari浏览器 **终极写法:** `c.Header("Content-Disposition", fmt.Sprintf("attachment; filename*=utf-8''%s", url.QueryEscape(showFileName)))` Safari浏览器也不乱码了 相关阅读: ![image.png](https://static.studygolang.com/211222/758e5f9c4c9b303466bcbabff2273e18.png) **"filename" 和 "filename*" 两个参数区别的参考:**[Content-Disposition](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Content-Disposition)