1

I want to know how can i do from ftp_fget, ftp_nb_fget to transfert ? Because when I insert just "ok" in output, it's work but when I insert string data of PHP://temp from ftp_fget() no but the program have an issue (HTTP Error : ERR_INVALID_RESPONSE).

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filename.'.tar.gz');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . ftp_size($server, $filename)); //Remove
$tempHandle = fopen('php://temp', 'r+'); 
if (@ftp_fget($server, $tempHandle, $filename, FTP_ASCII, 0)) { 
    rewind($tempHandle); 
    echo stream_get_contents($tempHandle);
}
  • 1
    *"have an issue"* is not a problem description. + Moreover why do you use `php://temp`? Why don't you use `php://output`? See [Download file via PHP script from FTP server to browser with Content-Length header without storing the file on the web server](https://stackoverflow.com/q/47240635/850848). – Martin Prikryl Jun 28 '19 at 13:39
  • 1
    Okay I haven't see the limit of temp. Thanks for link, it's useful and now it works –  Jun 28 '19 at 14:04

0 Answers0