开发者

Replace %20 with spaces when downloading files?

开发者 https://www.devze.com 2022-12-31 02:15 出处:网络
Is it possible to get a url/downloaded file name change the \"%20\" to spaces? Like instead of downloading the file my%20file.pdf, download my file.pdf? I\'d like to use PHP开发者_如何学C if possible.

Is it possible to get a url/downloaded file name change the "%20" to spaces? Like instead of downloading the file my%20file.pdf, download my file.pdf? I'd like to use PHP开发者_如何学C if possible...


You will need to make use of the Content-disposition header.

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.


I think you can use the Content-Disposition header to force a "Save As" dialog and recommend a file name like so:

header('Content-Disposition: attachment; filename="my file.pdf"');

The PHP.net page on header() seems to suggest the same.

0

精彩评论

暂无评论...
验证码 换一张
取 消