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

后端 未结 6 500
你的背包
你的背包 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:32

    I use a method similar to this for downloading mp4 files, could work for text files:

    $file=fopen('http://example.com/example.txt','r');
    header("Content-Type:text/plain");
    header("Content-Disposition: attachment; filename="example.txt");
    fpassthru($file);
    

提交回复
热议问题