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,
imports the ftp module.
makes a ftp connection to the ftp server with the specified ftp server with the supplied username/password.
opens the cup.mp4 file. And then
uploads the file to ftp server.Finally we close the file with
and then close the session
'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
Post a Comment