S
S
SHAKIRA2014-09-02 01:00:28
Delphi
SHAKIRA, 2014-09-02 01:00:28

IdFTP.Put component corrupts files in RAD Studio XE 6, can you help me fix it?

Hello! To send files to FTP in Delphi I use this function

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;

But faced with the fact that it damages the files when sending, and it becomes unreadable. Please tell me what is wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Egor, 2016-12-26
@GBreazz

In this case, the problem most likely lies in the fact that the data transfer mode is set to ASCII. In this mode, control characters are interpreted incorrectly for binary files. The binary type means that the server transfers files without any processing, as is. You need to set the TransferType property of the idFTP component to ftBinary

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question