現在、PHP を使用して、サーバーとリモート FTPS (FTP over SSL) サーバー間で小さなファイルを転送しようとしています。私は、次のストリーム コンテキストを使用して、これを行うための標準的なフェアです。つまり、file_put_contents、file_get_contents などです。
stream_context_create(array('ftp' => array('overwrite' => true), 'ssl' => array('allow_self_signed' => true)))
次のコードを使用して、このコンテキスト ストリームを渡します。FTPS サーバーには問題なく接続できますが、リモート ファイルの作成に関しては、ファイル自体が完全に空です。ファイル サイズは 0 のように空です。
if(false === file_exists($localFile))
{
throw new Exception("Local file, {$localFile}, does not exist.");
}
if(false === $localFileContents = file_get_contents($localFile))
{
throw new Exception("Could not open Local file, {$localFile}.");
}
if(false === file_put_contents("{$this->url}{$remoteFile}", $localFileContents, FILE_APPEND, $this->context))
{
throw new Exception("Could not write to remote file, {$remoteFile}.");
}
リモート ファイルの場所、つまり $this->url は次の形式です: "ftps://{user}:{pass}@{host}:{port}"
現在、Windows/Apache セットアップを使用しているため、独自の PHP バイナリをコンパイルせずに ftp_ssl_connect() を使用することはできません。環境の大きな変化なので、とにかくこの道を進むことはできませんでした。