Sample code for 30+ languages & platforms
Swift

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

Swift

func chilkatTest() {
    var success: Bool = false

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

    let ftp = CkoFtp2()!

    ftp.hostname = "ftp.example.com"
    ftp.username = "my_login"
    ftp.password = "my_password"

    // Connect and login to the FTP server.
    success = ftp.connect()
    if success != true {
        print("\(ftp.lastErrorText!)")
        return
    }

    // Change to the remote directory where the files will be uploaded.
    // for the FTP account.
    success = ftp.changeRemoteDir(relativeDirPath: "junk")
    if success != true {
        print("\(ftp.lastErrorText!)")
        return
    }

    // Upload all files with filenames matching "c:/temp/ftp_*.asp"
    var numFilesUploaded: Int = ftp.mPutFiles(pattern: "c:/temp/ftp_*.asp").intValue
    if numFilesUploaded < 0 {
        print("\(ftp.lastErrorText!)")
        return
    }

    success = ftp.disconnect()

    print("\(numFilesUploaded) Files Uploaded!")

}