ftp (file transfert protocol)

envoi de fichier

import ftplib
import os
def sendFtp(ftp_host, ftp_user, ftp_pass, file):
    ftp = ftplib.FTP(ftp_host)
    ftp.login(ftp_user, ftp_pass)
    ext = os.path.splitext(file)[1]
    if ext in (".txt", ".htm", ".csv", ".html"):
        ftp.storlines("STOR " + file, open(file))
    else:
        ftp.storbinary("STOR " + file, open(file, "rb"), 1024)