How to use Indy FTP on FreePascal/Lazarus:
1) Place a TIdFTP component on your form (logic :-) ) from "Indy Client Protocol (am)"
2) Place a TIdAntiFreeze component on your form from "Indy Misc (Core)"
3) Go to Project>Project Options>Compiler Options>Paths and add from Indy Package the directory "Lazarus" (in my case, "Paths" should look like this: ../indy-10.2.0.3/fpc;../indy-10.2.0.3/lazarus), otherwise you will receive the error "AntiFreeze.pas not found"
4) Configure FTP client with at least the following parameters:
- Host (yourftpsite.com or whatever that is)
- Username (your username, like username@yourftpsite.com)
- Password (your pasword)
- TransferType - FtBinary
- Pasive - True
- PasiveUserControlHost - True
Configuration may be different for specific ftp sites, but that's what worked for mine
5) A simple piece of code for upload files:
iftp1.Connect;
iftp1.Put('file1.txt');
iftp1.Put('file2.txt');
iftp1.Disconnect;
6) A simple piece of code for download files
iftp1.Connect;
iftp1.Get('file1.txt','file1.txt',true);
iftp1.Get('file1.txt','file2.txt',true);
iftp1.Disconnect;
Note:
- "true" in GET command is for overwrite
- Linux is case sensitive, so be careful how do you refer to your files
- Your Firewall settings may interfere, so be careful to that too
Niciun comentariu:
Trimiteți un comentariu