[英]Replace %20 with spaces when downloading files?
Is it possible to get a url/downloaded file name change the "%20" to spaces? 是否可以获取URL /下载的文件名将“%20”更改为空格? Like instead of downloading the file my%20file.pdf , download my file.pdf ? 喜欢而不是下载我的%20file.pdf文件,下载我的file.pdf ? I'd like to use PHP if possible... 我想尽可能使用PHP ...
You will need to make use of the Content-disposition
header. 您需要使用Content-disposition
标头。
Here's a relevant answer. 这是一个相关的答案。 Here's what the header might look like: 这是标题的样子:
Content-disposition: attachment; filename=my file.pdf
You could also use the reference for the header() function . 您还可以使用header()函数的引用。
I think you can use the Content-Disposition
header to force a "Save As" dialog and recommend a file name like so: 我认为您可以使用Content-Disposition
标头强制“另存为”对话框并推荐文件名,如下所示:
header('Content-Disposition: attachment; filename="my file.pdf"');
The PHP.net page on header()
seems to suggest the same. header()
上的PHP.net页面似乎表明相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.