php - Can't Upload folder to FTP Server : ftp_put(): SSL_shutdown failed
问题描述
I'm trying to upload all folder that are located in a specific folder ("Sending") to a FTP Server with that PHP Code :
$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);
But i have an error at this line :
ftp_put($conn_id, basename($filename), $filename, FTP_BINARY);
And the logs are
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.
There is something specific to my FTP Server : the connection port : 11876 is not the same as the Passive Transfer Port : 9317.
When I try to connect directly to the transfer port, the connection returns false.
Edit : I just figured out : The file is uploaded anyway so is there a way to remove this Warning and why does it appear?
But I can send folders trough Filezilla on the port 118976. What am I doing wrong? Can someone help me?
Logs from 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
解决方案
推荐阅读
- java - Windows 上的字符编码混淆
- ios - 交换 UITextField 的 isEnabled 更改背景颜色以及如何防止它
- python - Pandas 对 bp 进行分组,根据条件过滤和提取行
- java - 我怎样才能拥有这两个构造函数?
- python - 在 time.sleep(10) 之后运行时方法内的变量不更新 - python
- javascript - 使用 jsforce 无法通过 SalesForce Date 对象查询
- python-3.x - Django 动态模型表单
- classification - 重新采样后性能指标低下
- python - 如何使 TensorFlow 对象检测 API 警告静音?警告:张量流:AutoGraph 无法转换
每当我调用 Tensorflow 对象检测 API 的检测功能时,我都会得到所有这些日志记录:
警告:tensorflow:AutoGraph 无法转换 <object_detection.models.ssd_resnet_v1_
- sql - 如何在 SQL (Oracle) 中的可变数组中搜索字符串