Asked 7 years ago
14 Feb 2017
Views 1478
python

python posted

how to connect ftp server with PYTHON ?

how to connect ftp server with PYTHON and upload file to the server .
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

use pyftpdlib to connect with FTP



#define host
host=''
#define username
username=''
#define password
password=''
#define port
port=21

#loading all lib from pyftpdlib
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
from pyftpdlib.authorizers import DummyAuthorizer

#connecting ftp
authorizer = DummyAuthorizer()
authorizer.add_user(username,password,"/", perm='elradfmwM')

handler = FTPHandler
handler.authorizer=authorizer

server = FTPServer((host,port),handler)
server.serve_forever()



following code Instantiate a dummy authorizer for managing 'virtual' users

authorizer = DummyAuthorizer()



following code for Defining a new user having full r/w permissions and a read-only

authorizer.add_user(username,password,"/", perm='elradfmwM')


following code will Instantiate FTP handler class

    handler = FTPHandler
    handler.authorizer = authorizer


start ftp server

server.serve_forever()

Post Answer