首页 > php代码 > php 复制目录及目录下所有文件

php 复制目录及目录下所有文件

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.', '<br />';
   }
   return true;
  }
 }

本文链接:http://www.phprm.com/code/fbc575efa606a53f6b627e8c866b0e35.html

收藏随意^^请保留教程地址.

标签:none

发表留言