DataFlex
DataFlex
Save String Variable to File on FTP Server
See more FTP Examples
Save the contents of a string variable to a file on an FTP server.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoFtp
String sFileContents
String sRemoteFilename
String sTemp1
Move False To iSuccess
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatFtp2)) To hoFtp
If (Not(IsComObjectCreated(hoFtp))) Begin
Send CreateComObject of hoFtp
End
Set ComHostname Of hoFtp To "ftp.example.com"
Set ComUsername Of hoFtp To "login"
Set ComPassword Of hoFtp To "password"
// Connect and login to the FTP server.
Get ComConnect Of hoFtp To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
// Change to the remote directory where the existing file is located.
Get ComChangeRemoteDir Of hoFtp "junk" To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
// Upload the contents of a string to a remote file.
Move "To be, or not to be: that is the question." To sFileContents
Move "hamletQuote.txt" To sRemoteFilename
Get ComPutFileFromTextData Of hoFtp sRemoteFilename sFileContents To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComDisconnect Of hoFtp To iSuccess
Showln "String Uploaded!"
End_Procedure