i have this doubt, i can download all files from an specific directory, but how can i download all files from all directories in an specific folder? My code to download from a directory is like this:
$ftp_server = "server";
$ftp_user = "user";
$ftp_pass = "pass";
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
function get_file($strDir) {
global $conn_id;
$contents = ftp_nlist($conn_id, $strDir);
for($i=0; $i<count($contents); $i++) {
if (strstr($contents[$i], "OUT") !== FALSE) {
if (ftp_get($conn_id, substr($contents[$i],1), $contents[$i], FTP_ASCII)) {
echo "Successfully written to ".substr($contents[$i],1)."<br>";
} else {
echo "There was a problem ".substr($contents[$i],1)."<br>";
}
}
else {
mkdir(substr($contents[$i],1),0777,true);
$a = get_file($contents[$i]);
}
}
return 1;
}
if (ftp_login($conn_id, $ftp_user, $ftp_pass)) {
$contents = ftp_nlist($conn_id, "OUT");
for($i=0; $i<count($contents); $i++) {
echo "Directory = " . $contents[$i] . "<br>";
ftp_get($conn_id, $contents[$i], $contents[$i], FTP_BINARY);
}
}
so, how can i download ALL the files from ALL directories?