//copy dir
function full_copy($source, $target, $exclude = array()) {
//print "Copying " . $source ."\n";
if (is_dir ( $source )) {
if( !is_dir($target) )
@mkdir ( $target, 0755, true);
$d = @dir ( $source );
if( $d )
{
while ( FALSE !== ($entry = $d->read ()) ) {
if ($entry == '.' || $entry == '..' || $entry == '.svn') {
continue;
}
$Entry = $source . '/' . $entry;
if (in_array($Entry,$exclude)) {
continue;
}
if( substr($target, -1, 1)=="/" )
$targetPath = $target . $entry;
else
$targetPath = $target . "/" . $entry;
if (is_dir ( $Entry )) {
$this->full_copy ( $Entry, $targetPath, $exclude );
continue;
}
$cRst = copy ( $Entry, $targetPath );
}
$d->close ();
}
}
else {
copy ( $source, $target );
}
}COPY一个目录底下所有文件的函数
最新推荐文章于 2024-08-25 03:31:49 发布
本文介绍了一个PHP函数full_copy,用于完整地复制一个目录及其所有文件到另一个位置,并提供了排除特定文件的功能。该函数通过递归方式实现,可以处理复杂的目录结构。

9980

被折叠的 条评论
为什么被折叠?



