(Swift) Upload Directory Tree
Upload an entire directory tree from the local filesystem to an FTP server.
func chilkatTest() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let ftp = CkoFtp2()!
ftp.keepSessionLog = true
ftp.hostname = "ftp.example.com"
ftp.username = "login"
ftp.password = "password"
// Connect and login to the FTP server.
var success: Bool = ftp.connect()
if success != true {
print("\(ftp.lastErrorText!)")
return
}
// Set the current remote directory to the root where the
// directory tree will be uploaded.
success = ftp.changeRemoteDir("/something")
if success != true {
print("\(ftp.lastErrorText!)")
return
}
// Upload the entire directory tree rooted at c:/temp/something
success = ftp.putTree("c:/temp/something")
if success != true {
print("\(ftp.lastErrorText!)")
return
}
success = ftp.disconnect()
print("\(ftp.sessionLog!)")
}
|