from ftplib import FTP
import sys, os
# Connect
ftp = FTP('serverName')
ftp.login('user', 'password')
# Directory of the local files
root = "path/to/root/directory/"
for path, subdirs, files in os.walk(root):
for name in files:
fp = open(name, 'rb') # File to send
ftp.storbinary('STOR ' + name, fp) # Send file
fp.close() # Close file
ftp.quit() # close fpt connection