PHP Pass File Handle to user so that file downloads & saves to their machine

前端 未结 2 1913
傲寒
傲寒 2021-01-17 05:15

I am downloading a file from another server. I wish to push this file to my users rather than saving it to my server.

In other words, pass them the file handle so i

2条回答
  •  耶瑟儿~
    2021-01-17 05:42

    You can try this

    $filetype = mime_content_type($filename);
    header('Content-type: '.$filetype);
    header('Content-Disposition: attachment; filename="'.$filename.'"');
    

    UPDATE for your EDIT:

    Do you have errors disabled, since this sounds like the headers already sent error?

    error_reporting(E_ALL | E_STRICT);
    

提交回复
热议问题