Sample code for 30+ languages & platforms
Xbase++

Upload Directory Tree

See more FTP Examples

Upload an entire directory tree from the local filesystem to an FTP server.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oFtp

nSuccess := 0

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

oFtp := CreateObject("Chilkat.Ftp2")

oFtp:KeepSessionLog := 1

oFtp:Hostname := "ftp.example.com"
oFtp:Username := "login"
oFtp:Password := "password"

//  Connect and login to the FTP server.
nSuccess := oFtp:Connect()
IF (nSuccess != 1)
    ? oFtp:LastErrorText
    oFtp:destroy()
    RETURN
ENDIF

//  Set the current remote directory to the root where the
//  directory tree will be uploaded.
nSuccess := oFtp:ChangeRemoteDir("/something")
IF (nSuccess != 1)
    ? oFtp:LastErrorText
    oFtp:destroy()
    RETURN
ENDIF

//  Upload the entire directory tree rooted at c:/temp/something
nSuccess := oFtp:PutTree("c:/temp/something")
IF (nSuccess != 1)
    ? oFtp:LastErrorText
    oFtp:destroy()
    RETURN
ENDIF

nSuccess := oFtp:Disconnect()

? oFtp:SessionLog

oFtp:destroy()