import ftplib
host = "XXXX"
ftp_user = "XXXX"
ftp_password = "XXXX"
filename = "txt.txt"
FTP_TIMEOUT = 10
con = ftplib.FTP(host, ftp_user, ftp_password, FTP_TIMEOUT)
con.set_pasv("true")
f = open(filename, "rb")
con.cwd('htdocs')
con.storbinary("STOR "+ filename, f)
con.close()