0

I'm really struggling just to get a simple .txt file to upload to a FTP server. I've got a folder on my desktop which contains two files: text.txt and upload_to_ftp.py.

I've tried these:
FTP file upload
Python Script Uploading files via FTP
But neither seem to work.

I've re-written the code so many times its doing my head in and i keep getting errors such as:

sftp = ftplib.FTP('REMOTEFTPSITE.com', 'MYUSERNAME', 'MYPASSWORD')
File "C:\Python27\lib\ftplib.py", line 117, in __init__
self.connect(host)
File "C:\Python27\lib\ftplib.py", line 135, in connect
self.welcome = self.getresp()
File "C:\Python27\lib\ftplib.py", line 210, in getresp
resp = self.getmultiline()
File "C:\Python27\lib\ftplib.py", line 196, in getmultiline
line = self.getline()
File "C:\Python27\lib\ftplib.py", line 183, in getline
line = self.file.readline()
File "C:\Python27\lib\socket.py", line 447, in readline
data = self._sock.recv(self._rbufsize)
error: [Errno 10054] An existing connection was forcibly closed by the remote host

Any help would be great! Thanks in advance.

Community
  • 1
  • 1
koop
  • 1
  • 2
  • 1
    Just to make certain all is well, make sure that your server/username/password works in an existing FTP client. – PearsonArtPhoto Feb 07 '13 at 02:55
  • Thanks for your reply. I did check that. Thank you anyway. – koop Feb 07 '13 at 03:16
  • 1
    ah! fixed. I was just putting editing the file with username and password without putting user='username' and pass='password' oops fail. – koop Feb 07 '13 at 03:34
  • 1
    You might want to put this into your answer at the end under a heading like "SOLVED: forgot blah" – daviewales Feb 07 '13 at 05:02

1 Answers1

0

Make sure you actually supplied a server, username, and password in this line:

sftp = ftplib.FTP('REMOTEFTPSITE.com', 'MYUSERNAME', 'MYPASSWORD')
PearsonArtPhoto
  • 38,970
  • 17
  • 111
  • 142