Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. IdFTP1.Host:='shabala.com';
  2. IdFTP1.Passive:=True;
  3. IdFTP1.TransferType:=ftBinary;
  4. IdFTP1.Username:='******';
  5. IdFTP1.Password:='******';
  6. IdFTP1.Port:=21;
  7.  
  8. IdFTP1.Connect(True);
  9. //IdFTP1.ChangeDir('/Sessions');
  10. IdFTP1.Put(GetCurrentDir+''+Token+'.cmd',Token+'.cmd', False);
  11. IdFTP1.Quit;
  12. IdFTP1.Disconnect;
  13.  
  14. Token: String;
  15.  
  16. uses
  17. ...
  18. OverbyteIcsFtpCli;
  19.  
  20. procedure FtpUploadFile(
  21. HostName: String;
  22. UserName: String;
  23. Password: String;
  24. UploadFileName: String;
  25. ToHostDir : String );
  26. var
  27. FTP: TFtpClient;
  28. begin
  29. FTP := TFtpClient.Create(nil);
  30. try
  31. FTP.HostName := HostName;
  32. FTP.Passive := True;
  33. FTP.Binary := True;
  34. FTP.Username := UserName;
  35. FTP.Password := Password;
  36. FTP.Port := '21';
  37.  
  38. if not FTP.Open then
  39. raise Exception.Create('Failed to connect: ' + FTP.ErrorMessage);
  40.  
  41. if (not FTP.User) or (not FTP.Pass) then
  42. raise Exception.Create('Failed to login: ' + FTP.ErrorMessage);
  43.  
  44. FTP.HostDirName := ToHostDir;
  45. if not FTP.Cwd then
  46. raise Exception.Create('Failed to change dir: ' + FTP.ErrorMessage);
  47.  
  48. FTP.LocalFileName := UploadFileName;
  49. FTP.HostFileName := ExtractFileName(UploadFileName);
  50.  
  51. if not FTP.Put then
  52. raise Exception.Create('Failed to upload file: ' + FTP.ErrorMessage);
  53. finally
  54. FTP.Free;
  55. end;
  56. end;
  57.  
  58. procedure TForm1.Button1Click(Sender: TObject);
  59. begin
  60. FtpLoadFile('rubilaxe.hostoi.com',
  61. '******', '******',
  62. IncludeTrailingPathDelimiter(
  63. ExtractFilePath(Application.ExeName) ) +'datafile.zip',
  64. '/files' );
  65. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement