-
-
Save manxisuo/7931bd307405912217d58f0d6216acf3 to your computer and use it in GitHub Desktop.
A sample example for uploading files using ftp in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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