Sample code for 30+ languages & platforms
PowerBuilder

Append to Existing File on FTP Server

See more FTP Examples

Uploads a file to the FTP server. If the remote file (on the FTP server) does not already exist, it is created. Otherwise the uploaded file is appended to the remote file.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Ftp
string ls_LocalFilePath
string ls_RemoteFilename

li_Success = 0

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Ftp = create oleobject
li_rc = loo_Ftp.ConnectToNewObject("Chilkat.Ftp2")
if li_rc < 0 then
    destroy loo_Ftp
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Ftp.Hostname = "ftp.myftpserver.com"
loo_Ftp.Username = "myUsername"
loo_Ftp.Password = "myPassword"

// Connect to the FTP server.
li_Success = loo_Ftp.ConnectOnly()
if li_Success <> 1 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if

// Authenticate with the FTP server.
li_Success = loo_Ftp.LoginAfterConnectOnly()
if li_Success <> 1 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if

ls_LocalFilePath = "/someDirectory/hamlet.xml"
ls_RemoteFilename = "hamlet.xml"

// Upload to the FTP server, creating the file if it does not yet exist
// on the FTP server, or appending to the remote file if it already exists.
li_Success = loo_Ftp.AppendFile(ls_LocalFilePath,ls_RemoteFilename)
if li_Success <> 1 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if

loo_Ftp.Disconnect()

Write-Debug "Success."


destroy loo_Ftp