I used the filezilla server to create the ftp server. The ssl option is open on ports 21 and 990. I tried using the filezilla client to upload and download the file is still working well.I try upload file to FTP server use ftplib. Here my code:
from ftplib import FTP_TLS, FTP
import socket
import ssl
file = open('test.py','rb')
ftps = FTP_TLS()
ftps.set_debuglevel(2)
s = ftps.connect(host='192.168.1.102', port=21)
ftps.login(user="xxx", passwd="xxxxxx")
ftps.prot_p()
ftps.storbinary("STOR test.py", file)
And get error :
*get* '227 Entering Passive Mode (192,168,1,102,19,170)\r\n'
*resp* '227 Entering Passive Mode (192,168,1,102,19,170)'
*cmd* 'STOR test.py'
*put* 'STOR test.py\r\n'
*get* '150 Opening data channel for file upload to server of "/test.py"\r\n'
*resp* '150 Opening data channel for file upload to server of "/test.py"'
Traceback (most recent call last):
File "ImplicitFTP.py", line 49, in <module>
ftps.storbinary("STOR test.py", file)
File "C:\Python27\lib\ftplib.py", line 760, in storbinary
conn = self.transfercmd(cmd, rest)
File "C:\Python27\lib\ftplib.py", line 376, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "C:\Python27\lib\ftplib.py", line 713, in ntransfercmd
server_hostname=self.host)
File "C:\Python27\lib\ssl.py", line 363, in wrap_socket
_context=self)
File "C:\Python27\lib\ssl.py", line 611, in __init__
self.do_handshake()
File "C:\Python27\lib\ssl.py", line 840, in do_handshake
self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:661)
Please help me. Thanks