Answer the question
In order to leave comments, you need to log in
Why can't this function of sending files to FTP be written in Delphi?
procedure FTPUpload();
var IdFTP:TIdFtp;
dn:integer;
F: TSearchRec;
ftpset:TstringList;
ftphost, ftpport, ftplogin, ftppassword, ftpdir: String;
begin
ftpset:=TStringList.Create;
ftpset.LoadFromFile(dir+'/ftp.txt');
ftphost:=Copy(ftpset[0], 6, length(ftpset[0]));
ftpport:=Copy(ftpset[1], 6, length(ftpset[1]));
ftplogin:=Copy(ftpset[2], 7, length(ftpset[2]));
ftppassword:=Copy(ftpset[3], 10, length(ftpset[3]));
ftpdir:=Copy(ftpset[4], 11, length(ftpset[4]));
Form1.Label1.Caption:= 'Зарузка файлов на FTP сервер...';
try
IdFTP:=TIdFTP.Create(nil);
if IdFTP.Connected then
begin
IdFTP.Abort;
IdFTP.Quit;
end;
IdFTP.Username := ftplogin;
IdFTP.Password := ftppassword;
IdFTP.Host := ftphost;
try
IdFTP.Connect;
if IdFTP.Connected then
begin
IdFTP.ChangeDir(ftpdir);
chdir(dir+'\acestream');
dn := FindFirst('*.*',faArchive,F);
while dn = 0 do
begin
IdFTP.Put(dir+'\acestream\'+f.name,f.name, True);
dn := FindNext(F);
end;
//IdFTP.Quit;
end;
Form1.Label1.Caption:= 'Зарузка файлов на FTP сервер...';
except
ShowMessage('Ошибка отправки.');
end;
finally
IdFTP.Free;
end;
end;
if IdFTP.Connected then
begin
IdFTP.Abort;
IdFTP.Quit;
end;
Answer the question
In order to leave comments, you need to log in
And what's the point of checking Connected and trying to complete it on a freshly created object?
How exactly does it not work? Exception? Which?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question