FTP (File transfer protocol) is used to send and receive files over the internet. I have issue with a lot of the supplied Gambas examples in that they often over-complicate the process they are trying to demonstrate. New users, searching for the answer to a particular problem, need the bare-bones answer: something on which they themselves can then build. Searching on ‘Gambas’ and ‘FTP’ currently leads to samples of amazing complexity with timers and event-logs all over the place to the point where you just can’t get the essence of the sample itself.
Well here is the bare-bones of FTP in Gambas:
‘ Gambas class file
PRIVATE myFTPClient AS NEW FtpClientPUBLIC SUB Button1_Click()
myFTPClient.URL=”ftp.drivehq.com/Documents/FileToSave.txt”
myFTPClient.User = “fred”
myFTPClient.Password = “dog”myFTPClient.Put(“/home/fred/FileToGo.txt”)
END
Now, how simple is that? The .URL includes the file name on the ftp server and the .Put gives the local filename that you want to send. You won’t be surprised to hear that there is a .get method to do it the other way round.
Ideally you would do a bit more e.g. monitor theFTPClient.status to check completion.
Make sure you click on networking components when you create the project (or click on gb.net and gb.net.curl in project,properties,components)