【www.gdgbn.com--安卓教程】

function copy($from, $to) {
  if ($this->abspath($to)=="/") $to=$this->basedir;
  if ($this->dirname($from) == $this->dirname($to)) $to = $this->dirname($to)."/复件".basename($from);
  if (!is_dir($from)) {
   return @copy($from, $to);
  } else {
   if (!is_dir($to)) @mkdir($to);
   $path = opendir($from);
   while( $file = readdir( $path ) ) {
    if (($file==".")||($file=="..")) continue;
    if (is_dir($from."/".$file)) $this->copy($from."/".$file, $to."/".$file);
    else echo basename($file), copy($from."/".$file, $to."/".$file) ? " Success!" : " False.", "
";
   }
   return true;
  }
 }

本文来源:http://www.gdgbn.com/shoujikaifa/22377/