const ftp = require("basic-ftp");
async function connectToFtp() {
const client = new ftp.Client();
try {
await client.access({
host: "ftp.example.com",
user: "your-username",
password: "your-password",
secure: true // 如果需要使用TLS/SSL连接,请设置为true
});
console.log("Connected to FTP server");
// 在这里进行FTP操作,例如上传、下载文件等
} catch (err) {
console.error(err);
} finally {
client.close();
}
}
connectToFtp();