View Full Version : In Python how do I use ftplib to upload a file to server

September 27th, 2009, 11:20 PM
def upload():
ftpserver = 'ftp.randomserver.com'
username = 'foo'
password = 'bar'
ftp = ftplib.FTP(ftpserver)
ftp.login(username, password)
#here i want to upload a file called file.html, how do I do this

I can log in fine, but can not for the life of me figure out how to upload a file to the FTP server. Any help is greatly appreciated!

September 27th, 2009, 11:56 PM
ftp.storlines("STOR %s" % filename, open(filename))