<?php
function copyDir($dirSrc,$dirTo){
if(is_file($dirTo)){
echo "目标不是目录不能创建";
return ;
}
if(!file_exists($dirTo)){
mkdir($dirTo);
}
if($dir_handle=@opendir($dirSrc)){
while ($filename = readdir($dir_handle)){
if($filename != "." && $filename != ".."){
$subSrcFile = $dirSrc."\\".$filename;
$subToFile = $dirTo."\\".$filename;
if(is_dir($subSrcFile)){
copyDir($subSrcFile,$subToFile);
}
if(is_file($subSrcFile)){
copy($subSrcFile,$subToFile);
}
}
}
closedir($dir_handle);
}
}
copyDir("myphp","D:\\admin");
?>
去掉盘附D:换成copyDir("myphp","admin") 就能把myphp复制到admin这个自动创建的文件夹下
只是我想把要复制的文件夹复制到其它盘的自动创建的文件夹下,一直都不对。
Warning: is_file() [function.is-file]: open_basedir restriction in effect. File(D:\admin) is not within the allowed path(s): (E:\web) in E:\web\copyFile.php on line 3Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(D:\admin) is not within the allowed path(s): (E:\web) in E:\web\copyFile.php on line 7Warning: mkdir() [function.mkdir]: open_basedir restriction in effect. File(D:\admin) is not within the allowed path(s): (E:\web) in E:\web\copyFile.php on line 8Warning: is_file() [function.is-file]: open_basedir restriction in effect. File(D:\admin\file) is not within the allowed path(s): (E:\web) in E:\web\copyFile.php on line 3Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(D:\admin\file) is not within the allowed path(s): (E:\web) in E:\web\copyFile.php on line 7Warning: mkdir() [function.mkdir]: open_basedir restriction in effect. File(D:\admin\file) is not within the allowed path(s): (E:\web) in E:\web\copyFile.php on line 8Warning: copy() [function.copy]: open_basedir restriction in effect. File(D:\admin\file\wo.txt) is not within the allowed path(s): (E:\web) in E:\web\copyFile.php on line 21Warning: copy(D:\admin\file\wo.txt) [function.copy]: failed to open stream: Operation not permitted in E:\web\copyFile.php on line 21Warning: copy() [function.copy]: open_basedir restriction in effect. File(D:\admin\in.txt) is not within the allowed path(s): (E:\web) in E:\web\copyFile.php on line 21Warning: copy(D:\admin\in.txt) [function.copy]: failed to open stream: Operation not permitted in E:\web\copyFile.php on line 21
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货