【发布时间】:2019-05-02 20:16:57
【问题描述】:
我尝试在 cpanel 中通过 ftp 上传文件,但服务器拒绝连接,我使用 FTP_TLS 似乎已连接,但在这种情况下我不知道如何上传文件
这是我的连接代码in FTP_TLS:
from ftplib import FTP_TLS
ftp=FTP_TLS()
ftp.set_debuglevel(2)
ftp.connect('ftp.EX.com')
ftp.sendcmd('ftp_usr')
ftp.sendcmd('ftp_pass')
ftp.dir()
ftp.close()
结果如下:
*get* '220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------\n'
*get* '220-You are user number 2 of 50 allowed.\n'
*get* '220-Local time is now 00:08. Server port: 21.\n'
*get* '220-This is a private system - No anonymous login\n'
*get* '220-IPv6 connections are also welcome on this server.\n'
*get* '220 You will be disconnected after 15 minutes of inactivity.\n'
*resp* '220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------\n220-You are user number 2 of 50 allowed.\n220-Local time is now 00:08. Server port: 21.\n220-This is a private system - No anonymous login\n220-IPv6 connections are also welcome on this server.\n220 You will be disconnected after 15 minutes of inactivity.'
*cmd* 'ftp_usr'
*put* 'ftp_usr\r\n'
我尝试这样上传示例文件,但结果与之前的注释相同,没有任何改变:
ftp=FTP_TLS()
ftp.set_debuglevel(2)
ftp.connect('ftp.EX.com')
ftp.sendcmd('ftp_usr')
ftp.sendcmd('ftp_pass')
file = open('imaege.jpg','rb')
ftp.storbinary('STOR image.jpg', file)
ftp.dir()
ftp.close()
【问题讨论】: