Rust
Rust
Upload Directory Tree
See more FTP Examples
Upload an entire directory tree from the local filesystem to an FTP server.Chilkat Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let ftp = chilkat::Ftp2::new();
ftp.set_keep_session_log(true);
ftp.set_hostname("ftp.example.com");
ftp.set_username("login");
ftp.set_password("password");
// Connect and login to the FTP server.
if ftp.connect().is_err() {
println!("{}", ftp.last_error_text());
return;
}
// Set the current remote directory to the root where the
// directory tree will be uploaded.
if ftp.change_remote_dir("/something").is_err() {
println!("{}", ftp.last_error_text());
return;
}
// Upload the entire directory tree rooted at c:/temp/something
if ftp.put_tree("c:/temp/something").is_err() {
println!("{}", ftp.last_error_text());
return;
}
let _ = ftp.disconnect().is_ok();
println!("{}", ftp.session_log());