Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using python to upload a file to ftp server. My code is below
Python
import ftplib
s = ftplib.FTP('123.123.123.123', 'username', 'password')
f = open('filename to upload', 'rb')
s.storbinary('STOR filename', f)

This code gives me an error.
Python
soccet.error: [Errno 111] Connection refused


When I use C#.net to do this task, there is no problem at all. My c# code is below:
C#
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(FtpURL + filename);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.KeepAlive = true;
request.UseBinary = true;
request.UsePassive = false;
request.Credentials = new NetworkCredential(username, password);

FileStream fs = File.OpenRead(FullFilePath);
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
fs.Close();

Stream ftpstream = request.GetRequestStream();
ftpstream.Write(buffer, 0, buffer.Length);
ftpstream.Close();

Please help on this urgent issue!
Posted
Comments
Richard MacCutchan 20-Aug-15 3:35am    
Try it manually from a command prompt window to see what happens via direct ftp.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900