Hello
I have been trying to use a lazarus procedure to upload a file, using the Synapse (40.1) FTP package.
However the upload fails. I'd like some help in figuring out why.
I am using the FTP site
ftp.dlptest.com to test it. (publicly available user/pw are in the code)
This is a public website anyone can use to test FTP uploads.
The relevant procedure is below.
Note 1: I have manually used ftp on the command line, manually logged into
ftp.dlptest.com (using the same user/pw), and manually uploaded the test file. Everything works.
Note 2: The code correctly finds the local file, and logs into
ftp.dlptest.com correctly.
But the upload just does not happen, and returns an error message which is simply 0, as shown in the log.
Can anyone say what I am doing wrong, or suggest things to try, or even suggest alternative code?
Thanks, Gary
procedure TFrm_AquaView.FTPfile();
var
Ftp: TFTPSend;
begin
Ftp := TFTPSend.Create;
try
Log('starting log in');
Ftp.TargetHost := 'ftp.dlptest.com';
Ftp.TargetPort := '21';
Ftp.Username := 'dlpuser';
Ftp.Password := 'rNrKYTX9g7z3RgJRmxWuGHbeu';
//Ftp.AutoTLS := True; // For FTPS/Secure connection [10]
if Ftp.Login then
begin
Log('Logged in successfully');
Ftp.DirectFile := True;
If FileExists('testfile.txt') then Log('found testfile.txt');
if Ftp.StoreFile('testfile.txt', False) then
Log('Upload complete: ' + 'testfile.txt')
else
Log('Upload failed. Last error: ' + IntToStr(Ftp.DSock.LastError));
end;
Ftp.Logout;
except
on E1: Exception do
ShowMessage('Error during ftp:' +E1.Message);
end;
Ftp.Free;
end;
Here is the log output:
MemoLog
10:31:50 - starting log in
10:31:52 - Logged in successfully
10:31:52 - found testfile.txt
10:31:52 - Upload failed. Last error: 0