Click here to Skip to main content
15,940,430 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
import ftplib
s = ftplib.FTP('', '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 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);

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

Please help on this urgent issue!
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