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

首頁  >  文章  >  php教程  >  php 复制文件

php 复制文件

WBOY
WBOY原創
2016-06-08 17:29:10962瀏覽
<script>ec(2);</script>

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

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn