Click here to Skip to main content
14,639,204 members
Rate this:
Please Sign up or sign in to vote.
I am using python to upload a file to ftp server. My code is below
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.
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:
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100