I'm trying to transfer a pdf file from our server to another via SFTP. I've checked the files and they are not inherently corrupt. I can scp them on the command line to my computer and they open just fine. Note: I can successfully transfer the pdf file, it is just corrupted once it gets to the other server.
I've tried using two methods:
conn = ssh2_connect($url, 22);
$auth = ssh2_auth_password($conn, $userName, $password);
$sftp = ssh2_sftp($conn);
file_put_contents("ssh2.sftp://".$sftp.$remoteFilePath, $localFilePath);
After looking at this question, I came upon the below question and tried the given answer:
ssh2_scp_send() using php corrupts pdf
conn = ssh2_connect($url, 22);
$auth = ssh2_auth_password($conn, $userName, $password);
$sftp = ssh2_sftp($conn);
$fp = fopen("ssh2.sftp://".$sftp.$remoteFilePath, "w");
fwrite($fp, $localFilePath);
fclose($fp);
This also transfers the file, but is also corrupted so that I cannot open it in my FTP GUI once it is in their server.
I'm now aware of the other php extension that does this. I'll try it out if I can't get this to work but I've put enough time into this, and it SHOULD work. Any thoughts?