Sample code for 30+ languages & platforms
Dart

Use Explicit FTP over TLS

See more FTP Examples

Demonstrates how to connect to an FTP server using explicit FTP over TLS.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

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

  final ftp = CkFtp2();

  ftp.hostname = 'ftp.your-ftp-server.com';
  ftp.username = 'ftpAccountLogin';
  ftp.password = 'ftpAccountPassword';

  // Indicate that the "AUTH TLS" command should be use to convert the connection to TLS
  // after the initial TCP connection to port 21 is established.
  ftp.authTls = true;

  // Connect and convert the connection to TLS automatically.
  try {
    ftp.connectOnly();
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  try {
    ftp.loginAfterConnectOnly();
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  print('TLS connection established and successfully authenticated.');
}