public function putAll($source_directory, $target_directory, $mode = FTP_BINARY)
{
$d = dir($source_directory);
// do this for each file in the directory
while ($file = $d->read()) {
// to prevent an infinite loop
if ($file != "." && $file != "..") {
// do the following if it is a directory
if (is_dir($source_directory . '/' . $file)) {
if (!$this->isDir($target_directory . '/' . $file)) {
// create directories that do not yet exist
$this->ftp->mkdir($target_directory . '/' . $file);
}
// recursive part
$this->putAll($source_directory . '/' . $file, $target_directory . '/' . $file, $mode);
} else {
// put the files
$this->ftp->put($target_directory . '/' . $file, $source_directory . '/' . $file, $mode);
}
}
}
return $this;
}