Uploading a file using ftplib

In this post, you'll see how we can use ftplib to upload files to a ftp server. In the following example,

'import ftplib'

imports the ftp module.session = ftplib.FTP('example.com','username','password') 

makes a ftp connection to the ftp server with the specified ftp server with the supplied username/password.

file=open('cup.mp4','rb')

opens the cup.mp4 file. And then
session.storbinary('STOR cup.mp4',file)

uploads the file to ftp server.Finally we close the file with

file.close()

and then close the session

session.quit()

Comments

Popular posts from this blog

Automate file upload in Selenium IDE

How To Install and Configure Nextcloud