Skip to content

Instantly share code, notes, and snippets.

@tinshade
Created October 22, 2020 14:00
Show Gist options
  • Save tinshade/85dc495df7df0c659e5baffb42cacabb to your computer and use it in GitHub Desktop.
Save tinshade/85dc495df7df0c659e5baffb42cacabb to your computer and use it in GitHub Desktop.
Creating a FTP server with Python3 and transferring files.
#Start a server with: python -m pyftpdlib -p 21 -w --user="some_username" --password="some_password"
#Works for python3.x, didn't test for python2.x
import ftplib #Built-in library
session = ftplib.FTP('127.0.0.1', 'some_username' ,'some_password')
file = open('<filename with extension>','rb') # file to send
session.storbinary('STOR <recieved file name with extension>', 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