johnmahugu

python - send a file using ftp

Jun 14th, 2015
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import ftplib                                          # We import the FTP module
  2. session = ftplib.FTP('myserver.com','login','passord') # Connect to the FTP server
  3. myfile = open('toto.txt','rb')                         # Open the file to send
  4. session.storbinary('STOR toto.txt', myfile)            # Send the file
  5. myfile.close()                                         # Close the file
  6. session.quit()                                         # Close FTP session
Advertisement
Add Comment
Please, Sign In to add comment