function copyFile($dirs,$dirt) {//2个参数 //判断文件是否存在, if(file_exists($dirt)) { if(!is_dir($dirt)) { echo '目标不是目录,无法copy
'; exit; } }else{ mkdir($dirt); } $dir = opendir($dirs); while($dirname = readdir($dir)) { if($dirname != "." && $dirname != "..") { $files = $dirs.'/'.$dirname;//原文件的路径 $filet = $dirt.'/'.$dirname;//赋值文件目标的路径 if(is_dir($files)) { copyFile($files,$filet);//递归处理赋值文件 }else{ copy($files,$filet); } } } closedir($dir); } copyFile("phpmyadmin","test/admin");//无法执行,提示 Warning: mkdir(): No such file or directory in D:\wamp\www\chapter12\dir_copy&move.php on line 46 copyFile("phpmyadmin","myadmin");//可以成功复制 copyFile("phpmyadmin","../phpmyadmin");//可以成功复制 copyFile("phpmyadmin","f:/myadmin");//可以成功复制如题,请问如何完善代码?谢谢 |