React Native
React Native
Upload Directory Tree
See more FTP Examples
Upload an entire directory tree from the local filesystem to an FTP server.Chilkat React Native Downloads
import { Ftp2 } from '@chilkat/react-native'
async function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const ftp = new Ftp2();
ftp.keepSessionLog = true;
ftp.hostname = 'ftp.example.com';
ftp.username = 'login';
ftp.password = 'password';
// Connect and login to the FTP server.
try {
await ftp.connectAsync();
} catch {
console.log(ftp.lastErrorText);
return;
}
// Set the current remote directory to the root where the
// directory tree will be uploaded.
try {
await ftp.changeRemoteDirAsync('/something');
} catch {
console.log(ftp.lastErrorText);
return;
}
// Upload the entire directory tree rooted at c:/temp/something
try {
await ftp.putTreeAsync('c:/temp/something');
} catch {
console.log(ftp.lastErrorText);
return;
}
await ftp.disconnectAsync();
console.log(ftp.sessionLog);
}