Wednesday, January 2, 2008

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()

No comments:

Post a Comment