Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import ftplib
  2. import os
  3.  
  4. def upload(ftp, file):
  5. ext = os.path.splitext(file)[1]
  6. if ext in (".txt", ".htm", ".html"):
  7. ftp.storlines("STOR " + file, open(file))
  8. else:
  9. ftp.storbinary("STOR " + file, open(file, "rb"), 1024)
  10.  
  11. ftp = ftplib.FTP("ftp.fbi.gov")
  12. ftp.login("mulder", "trustno1")
  13.  
  14. upload(ftp, "trixie.zip")
  15. upload(ftp, "file.txt")
  16. upload(ftp, "sightings.jpg")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement