How to encode the filename parameter of Content-Disposition header in HTTP?

前端 未结 18 1762
北荒
北荒 2020-11-21 06:15

Web applications that want to force a resource to be downloaded rather than directly rendered in a Web browser issue a Content-Disposition hea

18条回答
  •  日久生厌
    2020-11-21 06:55

    Put the file name in double quotes. Solved the problem for me. Like this:

    Content-Disposition: attachment; filename="My Report.doc"
    

    http://kb.mozillazine.org/Filenames_with_spaces_are_truncated_upon_download

    I've tested multiple options. Browsers do not support the specs and act differently, I believe double quotes is the best option.

提交回复
热议问题