Try this, from a comment on the manual page for copy:
function recurse_copy($src,$dst) {
$dir = opendir($src);
@mkdir($dst);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ) {
recurse_copy($src . '/' . $file,$dst . '/' . $file);
}
else {
copy($src . '/' . $file,$dst . '/' . $file);
}
}
}
closedir($dir);
}
Note that this solution will happily overwrite any files that exist in the $dst directory. If you want to avoid that, you could wrap the code in this question into a function, and call that function instead of copy.
I'm not sure what you want to transfer via FTP, if you clarify that I'll be happy to edit my answer.