0

I need to transfer files from Rpi to my computer. Rpi is connected to my computer with wifi. The FileZilla server is logged in into. But in the terminal when I run the FTPlib file I get this error: " socket.error: [Errno 111] Connection refused

import ftplib
server = '127.0.0.1'
username = 'localhost'
password = 'hello123'
ftp_connection = ftplib.FTP(server, username, password)
remote_path = "C:\Users\sai\Desktop\ImageS"
ftp_connection.cwd(remote_path)
fh = open("/home/pi/Desktop/ImageS/test.txt", 'rb')
ftp_connection.storbinary('STOR test.txt', fh)
fh.close()

1 Answers1

1

Your code does work with FileZilla in principal, I've just run it up on a Windows VM with FileZilla Server and a Pi with Python3. You'll need some configuring though.

server needs to be the IP address of the FTP server

The username and password need to be the ones configured in FileZilla settings. These are not the same ones as the 'admin interface' ones. Go to edit / users in the menu bar and add yourself a user, password and set a directory to act as their home /. The home directory is where you'll end up when you connect. You may want to grant write permissions to this too.

in edit /settings leave port 21 in place and go to the passive mode settings and configure a port range. I used 50000->50100 since I don't have anything there.

You'll also need to configure the Windows firewall to accept traffic on port 21 and the same range of other ports for Passive mode.

the remote_path variable needs to be based on the home you set for the user. So say you set the home to c:\ftp and you wanted the files in c:\ftp\dogs you set remote_path to /dogs (note the slashes don't mix to well between Linux and Windows).