Copiar un arbol de carpetas y archivos sin limite de niveles


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function copiarArbol($source, $dest){
  2. $folder = opendir($source);
  3. while($file = readdir($folder)){
  4. if ($file == '.' || $file == '..') continue;
  5. if(is_dir($source.'/'.$file)){
  6. if( !is_dir($dest.'/'.$file)) mkdir($dest.'/'.$file, 0666);
  7. copiarArbol($source.'/'.$file , $dest.'/'.$file);
  8. }else{
  9. if(strrchr($file,'.') != '.db'){
  10. copy($source.'/'.$file , $dest.'/'.$file );
  11. chmod($dest.'/'.$file , 0666);
  12. }
  13. }
  14. }
  15. closedir($folder);
  16. return 1;
  17. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.