Xceed FTP Library Documentation
Sending Files Delphi example
Example topics > Sending Files Delphi example

This example demonstrates the 7 following steps for receiving files:  

  1. Specify the FTP server's address 
  2. Specify the username to login 
  3. Specify the password for the username 
  4. Connect to the FTP server 
  5. Send files 
  6. Disconnect from the FTP server 
  7. Perform error handling  

The following code assumes you have placed an XceedFtp control on a form and have called it 'XceedFtp1' (the default name) .

Delphi Copy Code

XceedFtp1.License( 'your license key' );

XceedFtp1.ServerAddress := 'my.server.com'; {step (1)}
XceedFtp1.UserName := 'jacob'; {step (2)}
XceedFtp1.Password := 'ladder'; {step (3)}

try {step (7)}

   XceedFtp1.Connect; {step (4)}

   ShowMessage('Successfully connected to server. Starting upload.');

   try {step (7)}

      XceedFtp1.SendFile('c:\to upload\file.dat', 0, 'incoming\file.dat', False); {step (5)}

      { Use the SendMultipleFiles method if you want to use wildcards to send more than one file at a time. }
      ShowMessage('Successfully uploaded the file.');
   except
      on xErr: Exception do
          ShowMessage('Upload error. Description: '+ xErr.Message);
   end;

      XceedFtp1.Disconnect; {step (6)}
   except
      on xErr: Exception do
          ShowMessage('Connect error. Description: '+ xErr.Message);
end;