首页 > php代码 > 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/aa54caa0712912a126d1b7c6d36b38e9.html

欢迎收藏∩_∩但请保留本文链接。

标签:none

发表留言