Link to home
Start Free TrialLog in
Avatar of Simon
SimonFlag for Canada

asked on

Problem with Indy FTP file upload/download

Hi,
I have a problem uploading a file to an ftp server with Indy TidFTP component in Delphi 7.

When I run the code, I get the Socket Error # 10049 Cannot assign requested address error.
What am I doing wrong?

Thanks,
Dragan

ToUpload:=('c:\file.txt'); 
  with idFTP1 do
  begin
 
    Username := 'MyUsername'; 
    Password := 'MyPassword'; 
    Host := 'ftp.MyHost.com'; 
 
    if not Connected then Connect; 
 
      try
        ChangeDir('public/uploadfolder');
 
        Put(ToUpload, ExtractFileName(ToUpload));
        Quit; 
      except
         On E: Exception do
          begin
            ShowMessage(E.Message);
            Disconnect;
          end;
 
       end;
  end;

Open in new window

Avatar of SteveBay
SteveBay
Flag of United States of America image

Check for a firewall. Be sure to add your applicaiton to the exceptions list.
Avatar of Simon

ASKER

Firewall is off.
I can create a folder on the FTP server with Delphi, but cannot upload or download a file.

When I try to d/l a file, it creates a file on my machine with 0 bytes size, and then it throws the exception.
So the exception in the code above does not occure on "Connect" or  "ChangeDir" but does occure on "Put(ToUpload, ExtractFileName(ToUpload))".
Is this correct?
Avatar of Simon

ASKER

That is correct.
Hmm, that's what i was worried about.
Is this perhaps a rights issue? Have you tried doing a "Put" using command line FTP?
ASKER CERTIFIED SOLUTION
Avatar of Simon
Simon
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial