How do you initiate/force a download for files that reside externally in PHP or other language?

后端 未结 6 555
你的背包
你的背包 2021-01-25 12:54

If you have images or other files that reside externally, how do force the browser to download the link when a user click on it?

The use of \"Content-disposition: attac

6条回答
  •  长发绾君心
    2021-01-25 13:43

    I don't think it is possible to force a file download if you are not controlling the HTTP headers. Content-disposition: attachment is the only way I know of to accomplish this.

    Though this is probably not going to work, my only guess would be trying to combine Content-disposition with a Location header:

    Content-disposition: attachment; filename=myfile.jpg
    Location: http://www.somesite.com/myfile.jpg
    

    (it's a long shot, probably invalid and/or just bad practice)

提交回复
热议问题