This script uploads a file to an FTP server
1 2 3 4 5 6 7 8 9 10 11 12 13 | #!/usr/bin/python
import ftplib
server = 'yourftpserver.something'
username = 'yourusername'
password = 'yourpassword'
ftp_connection = ftplib.FTP(server, username, password)
remote_path = "/home/yourusername/ftp"
ft_connection.cwd(remote_path)
fh = open("filetouploadincludepath", 'rb')
ftp_connection.storbinary('STOR filetouploadwithoutpath', fh)
fh.close()
|
To set up an FTP server, see this article.