basedir; if ($this->dirname($from) == $this->dirname($to)) $to = "/> basedir; if ($this->dirname($from) == $this->dirname($to)) $to = ">
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;
}
}