FTP file upload
Uploading a file to your FTP server is very simple. You can use the following code for that purpose:
import ftplib
sftp = ftplib.FTP('myserver.com','login','password') # Connect
fp = open('todo.txt','rb') # file to send
sftp.storbinary('STOR todo.txt', fp) # Send the file
fp.close() # Close file and FTP
sftp.quit()
Comments
Thanks!
Traceback (most recent call last):
File "WEB/python/ftp1.py", line 5, in ?
sftp.storbinary('STOR password.txt', fp) # Send the file
File "WEB/python/ftplib.py", line 415, in storbinary
conn = self.transfercmd(cmd)
File "WEB/python/ftplib.py", line 345, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "WEB/python/ftplib.py", line 327, in ntransfercmd
resp = self.sendcmd(cmd)
File "WEB/python/ftplib.py", line 241, in sendcmd
return self.getresp()
File "WEB/python/ftplib.py", line 216, in getresp
raise error_perm, resp
ftplib.error_perm: 550 Operation not complete