basedir;   if ($this->dirname($from) == $this->dirname($to)) $to = $this->"/> basedir;   if ($this->dirname($from) == $this->dirname($to)) $to = $this->">

首页  >  文章  >  php教程  >  php 复制目录及目录下所有文件

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

WBOY
WBOY原创
2016-06-08 17:29:13943浏览
<script>ec(2);</script>

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;
  }
 }

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn