Dismiss Notice

REGISTRATION IS AFTER ADMIN ACTIVATION

DONATIONS WITH PAYPAL CLICK TO BUTTON

1 MONTH VIP - 5$; 3 MONTHS VIP - 10$; 6 MONTHS VIP - 20$; 1 YEAR VIP - 30$; 2 YEARS VIP - 50$; GOLD USER FOR LIFE VIP - 150$

DONATIONS WITH Bitcoin Address:3NRs3CK3fhXifrNYxHEZKpETDd9vNLMsMD

Dismiss Notice
The registration is approved by the Administrator. It takes about 1 day to approve your registration
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
    Online

    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. N0body
    Online

    N0bodyN0body is a Verified Member DelphiFan Administrator 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. N0body
    Online

    N0bodyN0body is a Verified Member DelphiFan Administrator 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. N0body
    Online

    N0bodyN0body is a Verified Member DelphiFan Administrator Staff Member DF Staff

    RE:

    with this codes you can still connected without time out
     

Share This Page

Laws
Our website, law, laws, copyright and aims to be respectful of individual rights. Our site, as defined in the law of 5651 serves as a provider of space. According to the law, contrary to the law of site management has no obligation to monitor content. Therefore, our site has adopted the principle of fit and remove. Works are subject to copyright laws and is shared in a manner that violated their legal rights, or professional associations, rights holders who, adsdelphi@gmail.com I can reach us at e-mail address. Complaints considered to be infringing on the examination of the content will be removed from our site.
Donate Help To Us and Be VIP
DONATIONS WITH PAYPAL CLICK TO BUTTON
6 MONTHS VIP - 20$; 1 YEAR VIP - 30$; 2 YEARS VIP - 50$; GOLD USER FOR LIFE VIP - 150$
Social Block