1
私は、ユーザがデータベースをCSVにエクスポートしてから、外部のFTPサーバにアップロードできる方法を作成しました。PHP - FTPに接続できません - 暗黙のSSLポート990
ローカルマシンでテストしたところ、すべてが正常に動作しているようです。
しかし、いったんコードを環境にプッシュすると、接続がタイムアウトしているように見えます。私はサーバーのタイムアウトを増やしましたが、それは助けに見えませんでした。
私は、次のエラーを取得しています、
There was an error in uploading the file :::: Failed to connect to xxx.xxx.xxx port 990: Connection timed out
コード
if ($fp = fopen($local, 'r')) {
$ftp_server = 'ftps://' . $this->server . '/' . $remote;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $ftp_server);
curl_setopt($ch, CURLOPT_PORT, 990);
curl_setopt($ch, CURLOPT_USERPWD, $this->username . ':' . $this->password);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FTP_SSL, CURLFTPSSL_ALL);
curl_setopt($ch, CURLOPT_FTPSSLAUTH, CURLFTPAUTH_TLS);
curl_setopt($ch, CURLOPT_UPLOAD, true);
curl_setopt($ch, CURLOPT_INFILE, $fp);
$result = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
if ($err) {
mail(ERROR_EMAIL, 'ERROR - Uploading file failed!.', date('F j, Y, g:i a e O')."] - There was an error in uploading the file :::: " . $err);
error_log("[".date('F j, Y, g:i a e O')."] - There was an error in uploading the file :::: " . $err . "\n", 3, __DIR__."/errors.log");
}
error_log("[".date('F j, Y, g:i a e O')."] - File Successfully Uploaded.\n", 3, __DIR__."/errors.log");
return !$err;
}
これは、クラス内で見つかった機能の内容です。私が何かを見逃しているのだろうか?
$remote -> this is the file path to the remote file. on the server.
$local -> this is the file on the local server.
ファイアウォールの問題である可能性があります。ポート990へのアクセスを許可しましたか? – BadHorsie
ありがとう、私はそれを見てみましょう。うまくいけば、原因とすべてのものが設定されて動作するthats。 – Adrian