Dart
Dart
Upload Directory Tree
See more FTP Examples
Upload an entire directory tree from the local filesystem to an FTP server.Chilkat Dart Downloads
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.keepSessionLog = true;
ftp.hostname = 'ftp.example.com';
ftp.username = 'login';
ftp.password = 'password';
// Connect and login to the FTP server.
try {
ftp.connect();
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
// Set the current remote directory to the root where the
// directory tree will be uploaded.
try {
ftp.changeRemoteDir('/something');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
// Upload the entire directory tree rooted at c:/temp/something
try {
ftp.putTree('c:/temp/something');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
ftp.disconnect();
print(ftp.sessionLog);
}