PHP无法将文件夹A复制到文件夹B.

时间:2018-05-25 05:52:54

标签: php

我从SOF找到了一些编码并尝试复制文件夹,但是,我收到了错误消息。我尝试在localhost上编码 - > XAMPP

编码

function recurse_copy($src,$dst) { 
    $dir = opendir($src); 
    @mkdir($dst); 
    while(false !== ( $file = readdir($dir)) ) { 
        if (( $file != '.' ) && ( $file != '..' )) { 
            if ( is_dir($src . '/' . $file) ) { 
                recurse_copy($src . '/' . $file,$dst . '/' . $file); 
            } 
            else { 
                copy($src . '/' . $file,$dst . '/' . $file); 
            } 
        } 
    } 
    closedir($dir); 
}
$current_dir=basename(__DIR__) ;
$src=$current_dir."/img";
$dst=$current_dir."/img2";


recurse_copy($src, $dst);

错误消息

Warning: opendir(hk_domain/img,hk_domain/img): ϵͳ�Ҳ���ָ����·���� (code: 3) in C:\xampp\htdocs\hk_domain\copy.php on line 4

Warning: opendir(hk_domain/img): failed to open dir: No such file or directory in C:\xampp\htdocs\hk_domain\copy.php on line 4

Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\hk_domain\copy.php on line 6

Warning: copy(hk_domain/img/): failed to open stream: No such file or directory in C:\xampp\htdocs\hk_domain\copy.php on line 12

Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\hk_domain\copy.php on line 6`

任何人都可以提供帮助?

0 个答案:

没有答案