Skip to content

Instantly share code, notes, and snippets.

@manxisuo
Forked from opnchaudhary/ftp_uploader.py
Last active October 6, 2018 03:12
Show Gist options
  • Save manxisuo/7931bd307405912217d58f0d6216acf3 to your computer and use it in GitHub Desktop.
Save manxisuo/7931bd307405912217d58f0d6216acf3 to your computer and use it in GitHub Desktop.
A sample example for uploading files using ftp in python
#!/usr/bin/python
import ftplib
def upload_1():
session = ftplib.FTP('example.com','username','password')
file = open('cup.mp4','rb') # file to send
session.storbinary('STOR '+'cup.mp4', file) # send the file
file.close() # close file and FTP
session.quit()
def upload_2():
session = ftplib.FTP()
session.connect('example.com', 10021)
session.login('username', 'password')
file = open('cup.mp4','rb') # file to send
session.storbinary('STOR '+'cup.mp4', file) # send the file
file.close() # close file and FTP
session.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment