2 个回答

检测下两者的Content-Type/Content-Disposition

https://stackoverflow.com/que...

Content-Type: application/octet-stream
Content-Disposition: attachment; filename="picture.png"
Means "I don't know what the hell this is. Please save it as a file, preferably named picture.png".

Content-Type: image/png
Content-Disposition: attachment; filename="picture.png"
Means "This is a PNG image. Please save it as a file, preferably named picture.png".

Content-Type: image/png
Content-Disposition: inline; filename="picture.png"
Means "This is a PNG image. Please display it unless you don't know how to display PNG images. Otherwise, or if the user chooses to save it, we recommend the name picture.png for the file you save it as".

楼上说的基本上就是了,我补充一点。 浏览器的安全策略有时候会阻止下载文件,有时候不同浏览器的实现也可能不太一样导致无法下载文件。 这个时候需要前端自己做一些兼容性处理

推荐问题
宣传栏