0
Well I managed to download a specific file from my FTP via php , but I need to download an entire directory someone knows how to do this, already found example in PHP manual more anything!
my code to download a specific file
<?php
// define some variables
$local_file = 'teste.pdf';
$server_file = './teste/teste1.pdf';
$ftp_server="ftp.exemplo.com";
$ftp_user_name="usuariopedro";
$ftp_porta="22";
$ftp_user_pass="senhapedro";
$conn_id = ftp_ssl_connect($ftp_server,$ftp_porta);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// turn passive mode on
ftp_pasv($conn_id, true);
// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
echo "Successfully written to $local_file\n";
}
else {
echo "There was a problem\n";
}
// close the connection
ftp_close($conn_id);
?>
take care of addresses, usernames and password.
– tvdias
yes, they are an example
– Kaleo
I added to the reply an example of how the files could be listed and the files downloaded.
– tvdias