Rust
Rust
Upload Multiple Files Matching Pattern
See more FTP Examples
The MPutFiles method can be called to upload all files matching a wildcarded filename pattern from a local filesystem directory.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_hostname("ftp.example.com");
ftp.set_username("my_login");
ftp.set_password("my_password");
// Connect and login to the FTP server.
if ftp.connect().is_err() {
println!("{}", ftp.last_error_text());
return;
}
// Change to the remote directory where the files will be uploaded.
// for the FTP account.
if ftp.change_remote_dir("junk").is_err() {
println!("{}", ftp.last_error_text());
return;
}
// Upload all files with filenames matching "c:/temp/ftp_*.asp"
let num_files_uploaded = ftp.m_put_files("c:/temp/ftp_*.asp");
if num_files_uploaded < 0 {
println!("{}", ftp.last_error_text());
return;
}
let _ = ftp.disconnect().is_ok();
println!("{} Files Uploaded!", num_files_uploaded);