Synapse FTP StoreFile lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- exdatis · 2013-02-25 14:03 Hi there. I tried to upload file to an FTP server, but to no avail. The connection is fine,  picture is there, no errors, but the picture is not uploaded on the server. What is wrong? --------- var   FTP: TFTPSend;   success : Boolean; begin   // ftp   FTP := TFTPSend.Create;   try     FTP.TargetHost := 'localhost';     //FTP.TargetPort := '21';     FTP.UserName := 'user';     FTP.Password := 'password';     FTP.Login; //ok     FTP.CreateDir('/my_path/ftp_test');//ok      //FTP.Logout;     FTP.ChangeWorkingDir('/my_path/ftp_test'); //everything is ok   except     on E : Exception do     begin       ShowMessage(E.Message);       Exit;     end;   end;                  picture_name:= 'picture_file';//ok                    with FTP do                    begin                      //ShowMessage(FTP.GetCurrentDir + '/' + picture_name);//ok                      FTP.DirectFileName:= picture_name;                      FTP.DirectFile:= True;                      success:= FTP.StoreFile(curr_picture, False);// same with True                      if success then                        ShowMessage('Ok')                      else                        ShowMessage('Grrrr...');//Grrrrrrrrrrrrrrrrrrr....                    end;       FTP.Logout;       FTP.Free;     end;            Synapse, openSuSe 12.2, vsftpd(ftp), Lazarus(1.1) 32 Thanks! ---------------------------------------------------------------------- exdatis · 2013-02-25 16:00 Works well with Indy(IdFTP)! ---   IdFTP1.Username:= 'user_name';   IdFTP1.Host:= 'localhost';   IdFTP1.Password:= 'user_pwd';   IdFTP1.Connect;   IdFTP1.MakeDir('/some_path/indy_pictures');   IdFTP1.ChangeDir('/some_path/indy_pictures');   IdFTP1.Put('/image_path/Img_name.jpg');   IdFTP1.Disconnect;  --- Success! ---------------------------------------------------------------------- BigChimp · 2013-02-25 16:18 Sorry, but Synapse works for me (I used Synapse trunk but release will quite probably work, too, FPC 2.6.0, Windows): QuoteD:\Cop\t>ftpupload sqldbtutorial3.exe Current FTP directory: /pub Upload ok Done. Code: [Select]program ftpupload; {$mode objfpc}{$H+} uses {$IFDEF UNIX} {$IFDEF UseCThreads}   cthreads, {$ENDIF} {$ENDIF}   Classes, sysutils,   ftpsend  // copy the synapse units over...   ; var   FTP: TFTPSend;   FTPHost: string;   SourceFile: string; begin   if Paramcount < 2 then   begin     writeln('Call with ');     exit;   end;   FTPHost := ParamStr(1);   SourceFile := ParamStr(2);   FTP := TFTPSend.Create;   try     try       FTP.TargetHost := FTPHost;       //FTP.TargetPort := '21';       FTP.UserName := 'anonymous';       FTP.Password := 'bla@example.com';       FTP.Login; //ok       FTP.ChangeWorkingDir('/pub'); //everything is ok     except       on E: Exception do       begin         writeln('Exception: '+E.Message);         Exit;       end;     end;     with FTP do     begin       writeln('Current FTP directory: '+FTP.GetCurrentDir);       FTP.DirectFile := true;       FTP.DirectFileName := SourceFile;       if FTP.StoreFile(SourceFile, false) then         writeln('Upload ok')       else         writeln('Grrrr...');//Grrrrrrrrrrrrrrrrrrr....     end;     FTP.Logout;   finally     FTP.Free;   end;   writeln('Done.'); end. File shows up nicely, uncorrupted on ftp server. ---------------------------------------------------------------------- exdatis · 2013-02-25 16:48 Thank you very much BigChimp! I'll try again. Regards! ---------------------------------------------------------------------- Pi · 2014-01-07 08:29 I've tried similar code to what BigChimp suggested, in a Lazarus application (not console app) to try to ftp a html file so it replaces an index.html file on a godaddy website but it fails to upload. I have a working verison in VisualBasic 2010 Express but I want to use the Synapse FTP function. For the Ftphost variable do I set it to 'ftp://.myftpupload.com' or 'ftp://.myftpupload.com/index.html' since index.html is the name of the file I'm trying to replace. I've tried both but it fails to upload. Do I need to use the "absolute hosting path" that godaddy gives? With the visualbasic 2010 program that works I don't need to use that. I've tried using FTP.ChangeWorkingDir to change to that but it still doesn't upload the file. Any ideas on what I need to do please?