Sample code for 30+ languages & platforms
Rust

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 Rust Downloads

Rust

// 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.myftpserver.com");
ftp.set_username("myUsername");
ftp.set_password("myPassword");

// Connect to the FTP server.
if ftp.connect_only().is_err() {
    println!("{}", ftp.last_error_text());
    return;
}

// Authenticate with the FTP server.
if ftp.login_after_connect_only().is_err() {
    println!("{}", ftp.last_error_text());
    return;
}

let local_file_path = "/someDirectory/hamlet.xml".to_string();
let remote_filename = "hamlet.xml".to_string();

// 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.
if ftp.append_file(&local_file_path, &remote_filename).is_err() {
    println!("{}", ftp.last_error_text());
    return;
}

let _ = ftp.disconnect();

println!("Success.");