1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

Help in FTP Put file

Discussion in 'Delphi Android And IOS' started by barakuda69, Mar 5, 2014.

  1. barakuda69
    Offline

    barakuda69 DF Senior DF Gold User

    I am developing an app which collects data and later be sent to a computer via ftp.
    Always disaggregate soil application in other to test separately ye here what would be the part that sends the file.

    The following code connects, validates and sends the file but it's like once sent Go Offline in the terminal not giving me error "Read timed out"


    Code:
    procedure TForm2.Button1Click(Sender: TObject);
    var
       clienteFtp: TIdFTP;
     begin
       clienteFtp := TIdFTP.Create(Self);
       try
         with clienteFtp do
         begin
           Username := 'david';
           Password := '1234';
           Host := '192.168.1.25';
           Connect; // Conectamos
           if connected  then
           begin
           ShowMessage('Conectado al servidor FTP');
           Put(TPath.Combine(TPath.GetDocumentsPath, 'subir.txt'), 'subir.txt', False);
           Disconnect;
           end;
    
         end;
          except
        on EConvertError  do
        ShowMessage('Error Al Conectar al servidor FTP');
       end;
     end;
    Curiously if I comment the line:

    Code:
    Put(TPath.Combine(TPath.GetDocumentsPath, 'subir.txt'), 'subir.txt', False);
    works correctly ie the client logs on to the FTP server, the terminal displays the message and accept you can see on the server that the client disconnected.
    Any suggestions,

    thanks in advance.
     
  2. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    RE:

    I don't know about the best way... but this will work.

    [DELPHI]procedure TForm1.KeepConnection;
    var S: String;
    begin
    If idFTP1.Connected then
    S := idFTP1.RetrieveCurrentDir;
    end;

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Application.OnIdle := KeepConnection;
    end;[/DELPHI]
     
  3. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    RE:

    and also 

    ...
    [DELPHI]type
    TForm1 = class(TForm)
    IdFTP1: TIdFTP;
    procedure KeepConnection(Sender: TObject; var Done: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure IdFTP1AfterClientLogin(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    var
    Form1: TForm1;
    LogedIn: Boolean;
    implementation

    {$R *.dfm}

    procedure TForm1.KeepConnection(Sender: TObject; var Done: Boolean);
    var S: String;
    begin
    If (idFTP1.Connected) and (LogedIn = true) then
    begin
    S := idFTP1.RetrieveCurrentDir;
    Done := False;
    end;
    end;

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    idftp1.Connect(true, 3000);
    idftp1.Login;
    Application.OnIdle := KeepConnection;
    end;

    procedure TForm1.IdFTP1AfterClientLogin(Sender: TObject);
    begin
    LogedIn := true;
    end;[/DELPHI]
    ...
     
  4. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    RE:

    with this codes you can still connected without time out
     

Share This Page