Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
FTP Upload File with Progress Monitoring
Delphi example program to upload a file to an FTP server with progress monitoring // FTP Upload a file to an FTP server with progress monitoring.
procedure TForm1.Button1Click(Sender: TObject);
var
success: Integer;
localFilename: WideString;
remoteFilename: WideString;
begin
// Import the Chilkat FTP-2 ActiveX control into Delphi and then
// drop an instance of the FTP control onto the form.
// Unlock once at the beginning of your program.
ChilkatFtp21.UnlockComponent('anything for 30-day trial');
ChilkatFtp21.Hostname := 'ftp.chilkatsoft.com';
ChilkatFtp21.Username := '***';
ChilkatFtp21.Password := '***';
// Connect to the server
success := ChilkatFtp21.Connect();
if (success = 1) then
begin
localFilename := 'test.txt';
remoteFilename := 'test.txt';
success := ChilkatFtp21.PutFile(localFilename,remoteFilename);
if (success = 0) then
begin
ChilkatFtp21.SaveLastError('ftpUploadError.txt');
ShowMessage('Error in upload. See error log');
end
else
ShowMessage('File uploaded!');
end
else
begin
ChilkatFtp21.SaveLastError('ftpConnectError.txt');
if (ChilkatFtp21.ConnectVerified = 1) then
ShowMessage('Login error. Check your username/password')
else
ShowMessage('Cannot connect to FTP server');
end;
end;
// Put (upload) event callback. This method is called each time
// the percentage-completion updates to a higher value.
procedure TForm1.ChilkatFtp21PutProgress(ASender: TObject;
pctDone: Integer);
begin
// pctDone holds an integer value between 1 and 100.
ProgressBar1.Position := pctDone;
end;
|
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.