无法将文件夹上传到FTP服务器:ftp_put():SSL_shutdown失败

时间:2019-06-26 15:23:37

标签: php ssl ftp port

我正在尝试使用该PHP代码将位于特定文件夹(“发送”)中的所有文件夹上载到FTP服务器:

$conn_id = ftp_ssl_connect($ftp_server, 11876);

$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_password);
if ((!$conn_id) || (!$login_result)) {
    echo "FTP Connection failed to server $ftp_server for user $ftp_user_name";
    exit;
} else {
    echo "Connected to Server $ftp_server, for user $ftp_user_name \r\n";
}

$remoteDir = "/Disque dur/Téléchargements/";
$dir = 'Sending';
$files = array_diff(scandir($dir), array('..', '.'));
$directories = array();
foreach ($files as $file) {
    if (is_dir($dir . '/' . $file))
        $directories[] = $file;
}
ftp_pasv($conn_id, true);

foreach ($directories as $directory) {
    if (ftp_chdir($conn_id, $remoteDir . $directory)) {
        echo "Current directory is now: " . ftp_pwd($conn_id) . "\n";
    } else {
        echo "Couldn't change directory\n";
        ftp_mkdir($conn_id, $remoteDir . $directory);
        ftp_chdir($conn_id, $remoteDir . $directory);
    }
    foreach (glob($dir . "/" . $directory . "/*.*") as $filename){
        ftp_put($conn_id, basename($filename), $filename, FTP_BINARY);
    }

}

ftp_close($conn_id);

但是我在这一行有一个错误:

ftp_put($conn_id, basename($filename), $filename, FTP_BINARY);

日志是

Connected to Server MYSERVER, for user USER
Current directory is now: /Disque dur/Téléchargements/DIRECTORY/
Warning: ftp_put(): SSL_shutdown failed
Warning: ftp_put(): Data channel closed.

我的FTP服务器有一些特定的东西:连接端口:11876与被动传输端口:9317不同。

当我尝试直接连接到传输端口时,连接返回false。

编辑:我刚刚发现:无论如何该文件都已上传,因此有什么方法可以删除此警告,为什么会出现?

但是我可以通过Filezilla在端口118976上发送文件夹。 我究竟做错了什么? 有人能帮我吗?

FileZilla的日志:

2019-06-26 18:12:30 13664 1 Status: Resolving address of ADRESS
2019-06-26 18:12:30 13664 1 Status: Connecting to IP:11876...
2019-06-26 18:12:30 13664 1 Status: Connection established, waiting for welcome message...
2019-06-26 18:12:30 13664 1 Response: 220 Welcome to Freebox FTP Server.
2019-06-26 18:12:30 13664 1 Command: AUTH TLS
2019-06-26 18:12:30 13664 1 Response: 234 Proceed with negotiation.
2019-06-26 18:12:30 13664 1 Status: Initializing TLS...
2019-06-26 18:12:30 13664 1 Status: Verifying certificate...
2019-06-26 18:12:30 13664 1 Status: TLS connection established.
2019-06-26 18:12:30 13664 1 Command: USER USERNAME
2019-06-26 18:12:30 13664 1 Response: 331 User name okay, need password.
2019-06-26 18:12:30 13664 1 Command: PASS ********************
2019-06-26 18:12:30 13664 1 Response: 230 User logged in, proceed.
2019-06-26 18:12:30 13664 1 Command: SYST
2019-06-26 18:12:30 13664 1 Response: 215 UNIX Type: L8
2019-06-26 18:12:30 13664 1 Command: FEAT
2019-06-26 18:12:30 13664 1 Response: 211-Extensions supported:
2019-06-26 18:12:30 13664 1 Response:  UTF8
2019-06-26 18:12:30 13664 1 Response:  EPRT
2019-06-26 18:12:30 13664 1 Response:  EPSV
2019-06-26 18:12:30 13664 1 Response:  REST STREAM
2019-06-26 18:12:30 13664 1 Response:  SIZE
2019-06-26 18:12:30 13664 1 Response:  CLNT
2019-06-26 18:12:30 13664 1 Response:  AUTH TLS
2019-06-26 18:12:30 13664 1 Response:  PBSZ
2019-06-26 18:12:30 13664 1 Response:  PROT
2019-06-26 18:12:30 13664 1 Response: 211 End
2019-06-26 18:12:30 13664 1 Command: CLNT FileZilla
2019-06-26 18:12:30 13664 1 Response: 200 Command Okay.
2019-06-26 18:12:30 13664 1 Command: OPTS UTF8 ON
2019-06-26 18:12:30 13664 1 Response: 200 Command Okay.
2019-06-26 18:12:30 13664 1 Command: PBSZ 0
2019-06-26 18:12:30 13664 1 Response: 200 Command Okay.
2019-06-26 18:12:30 13664 1 Command: PROT P
2019-06-26 18:12:30 13664 1 Response: 200 Command Okay.
2019-06-26 18:12:30 13664 1 Status: Logged in
2019-06-26 18:12:30 13664 1 Status: Retrieving directory listing...
2019-06-26 18:12:30 13664 1 Command: PWD
2019-06-26 18:12:30 13664 1 Response: 257 "/"
2019-06-26 18:12:30 13664 1 Command: TYPE I
2019-06-26 18:12:30 13664 1 Response: 200 Command Okay.
2019-06-26 18:12:30 13664 1 Command: PASV
2019-06-26 18:12:30 13664 1 Response: 227 PASV OK (IP)
2019-06-26 18:12:30 13664 1 Command: LIST
2019-06-26 18:12:30 13664 1 Response: 150 File Status OK.
2019-06-26 18:12:30 13664 1 Response: 226 Closing data connection.
2019-06-26 18:12:30 13664 1 Status: Directory listing of "/" successful

0 个答案:

没有答案
相关问题