Урок на Делфи 63. FTP - отправка, загрузка, удаление файла.
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdFTP,
Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
IdFTP1: TIdFTP;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
ftp: TIdFTP;
begin
ftp:=TIdFTP.Create(Application);
ftp.Host:='ya.ru';
ftp.Port:=21;
ftp.Username:='test';
ftp.Password:='test';
ftp.Passive:=True;
ftp.Connect;
If ftp.Connected=true then
begin
ftp.Put('c:\temp\Desert.bmp','Desert.bmp',false);
ftp.Get('Desert.bmp','c:\temp\Desertsposob1.bmp',true);
ftp.Delete('Desert.bmp');
end;
ftp.Disconnect;
FreeAndNil(ftp);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
idftp1.Host:='ya.ru';
idftp1.Port:=21;
idftp1.Username:='test';
idftp1.Password:='test';
idftp1.Passive:=True;
idftp1.Connect;
if IdFTP1.Connected=true then
begin
IdFTP1.Put('c:\temp\Desert.bmp','Desert.bmp',false);
IdFTP1.Get('Desert.bmp','c:\temp\Desertsposob2.bmp',true);
IdFTP1.Delete('Desert.bmp');
end;
//IdFTP1.Disconnect;
end;
end.