Alb*_*elB 5 html filenames http-headers
我强迫下载到浏览器的文件头部中设置进行处理Content-disposition,以inline;
有没有这样设置标题的方法?当前,看起来浏览器会自动使用文件的URL填充它。
是可以的,只要让你的URL末尾包含文件名,一定要对其进行URLEncode,大多数浏览器会忽略queryString
本地主机:3000/blah/blah/blah/Attachment%3A%20Screen%20Shot.png/?id=1670674338147205293
选项卡显示=“附件:屏幕截图.png”
在 Chrome、Firefox 和 Opera 上运行良好。。。Safari 根据您的设置显示域名或整个 URL
是的,您可以像为 那样指定文件名content-disposition: attachment,即如下所示:
Content-disposition: inline; filename="foo.bar"
Run Code Online (Sandbox Code Playgroud)
有关此标头的一些有用信息,请参阅这篇文章:How to Encode the filenameparameter of Content-Disposition header in HTTP?