How it works...

In this recipe, we assume that a local FTP server is running. Alternatively, you can connect to a remote FTP server. The ftp_upload() method uses the FTP() function of Python's ftplib to create an FTP connection object. With the login() method, it logs in to the server.

After a successful login, the ftp object sends the STOR command with either the storlines() or storbinary() method. The first method is used for sending ASCII text files such as HTML or text files. The latter method is used for binary data such as zipped archive.

It's a good idea to wrap these FTP methods with try-catch error-handling blocks, which is not shown here for the sake of brevity.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.47.169