Hello,
I use Lazarus 1.8.0 with LAMW (laztoapk) and synapse 4.0,
I try to download from FTP and save to FTP file.
If I run applications as an android application (via "[LAMW] Bulid Android Apk and Run" FTP connection does not work, I get "Can not login" for jButton1 and "Not uploaded" for pressing jButton2.
If the same procedures (changing TButton Buttons, and "Self.GetEnvironmentDirectoryPath (dirDownloads)" on windows directories and running via Run (in windows - F9), everything works and downloads and saves files from / to FTP.
Where is my mistake that I do not work on android?
unit1.pas:
unit unit1;
//{$mode delphi}
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, AndroidWidget, Laz_And_Controls, FTPSend;
type
{ TAndroidModule1 }
TAndroidModule1 = class(jForm)
jButton1: jButton;
jButton2: jButton;
aFTP: TFTPSend;
procedure jButton1Click(Sender: TObject);
procedure jButton2Click(Sender: TObject);
private
{private declarations}
public
{public declarations}
end;
var
AndroidModule1: TAndroidModule1;
implementation
{$R *.lfm}
{ TAndroidModule1 }
procedure TAndroidModule1.jButton1Click(Sender: TObject);
begin
what_download := 'time.txt';
try
aFTP := TFTPSend.Create;
try
aFTP.TargetHost := 'ftp.xxxx.pl';
aFTP.UserName := 'xxxx.pl';
aFTP.Password := '*****';
aFTP.BinaryMode := true;
aFTP.DirectFile := true;
aFTP.DirectFileName :=what_download;
aFTP.DirectFile := true;
if aFTP.Login then
begin
if not aFTP.RetrieveFile(Self.GetEnvironmentDirectoryPath(dirDownloads) + '/' + what_download,false) then
showmessage('Not downloaded');
aFTP.Logout;
end
else
showmessage('Can''t login');
finally
aFTP.free;
end;
finally
end;
end;
procedure TAndroidModule1.jButton2Click(Sender: TObject);
var
Result:Boolean;
what_upload : string;
begin
what_upload := 'time.txt';
Result := FtpPutFile('ftp.xxxx.pl', '21', Self.GetEnvironmentDirectoryPath(dirDownloads)+'/'+what_upload, what_upload, 'xxxx.pl', '*****');
if result then
showmessage('Uploaded')
else
showmessage('Not uploaded');
end;
end.