2016-09-07 20 views
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. 
+1

ファイアウォールの問題である可能性があります。ポート990へのアクセスを許可しましたか? – BadHorsie

+0

ありがとう、私はそれを見てみましょう。うまくいけば、原因とすべてのものが設定されて動作するthats。 – Adrian

答えて

0

問題は許可されないポート990としました。これはホスティングプロバイダの問題で、別の解決策をフォローアップしました。

コメントありがとうございました。私はしばらく時間を節約しました。

関連する問題