I am trying to get a pdf from an ftp server through the file_get_contents () function, but not what it is doing, I printed the last error that occurs and it returns me:
Array ( [type] => 2 [message] => file_get_contents('ftp://User:Pass@Host:port/Carpeta/archivo.pdf'): failed to open stream: FTP server reports 500 'ERROR ': command not understood.
I was investigating but I really did not find something specific that would give me to understand what I am doing wrong. the file exists in the FTP
the code is as follows:
$data = file_get_contents('ftp://User:Pass@Host:port/Carpeta/archivo.pdf');
that is the line that is failing, it is the first one. before that there is no code. as you will see the file I am trying to obtain a pdf and I do it that way because I do not want to save it on my server, the complete code for reference is this:
$data = base64_encode(file_get_contents('ftp://User:Pass@Host:port/Carpeta/archivo.pdf'));
$data2 = base64_decode($data);
header("Content-type: application/pdf");
header("Content-Length:" . strlen($data2));
echo $data2;