PHP copydir函数问题

PHP copydir函数问题,php,Php,我在下面的函数中遇到了一些问题,该函数假设要复制整个目录及其内容-opendir行每次返回时都无法打开,我不知道为什么。源确实存在,并且有755个权限(也尝试了757个权限,但仍然没有成功!) 有人能提出什么建议吗 function copydir($source,$destination) { if(!is_dir($destination)) { $oldumask = umask(0); mkdir($destination, 0757);

我在下面的函数中遇到了一些问题,该函数假设要复制整个目录及其内容-opendir行每次返回时都无法打开,我不知道为什么。源确实存在,并且有755个权限(也尝试了757个权限,但仍然没有成功!)

有人能提出什么建议吗

function copydir($source,$destination)
{
    if(!is_dir($destination))
    {
        $oldumask = umask(0); 
        mkdir($destination, 0757); // so you get the sticky bit set 
        umask($oldumask);
    }

    $dir_handle = @opendir($source) or die("Unable to open");
    while ($file = readdir($dir_handle)) 
    {
        if($file!="." && $file!=".." && !is_dir("$source/$file")) //if it is file
        {
            copy("$source/$file","$destination/$file");
        }

        if($file!="." && $file!=".." && is_dir("$source/$file")) //if it is folder
        {
            copydir("$source/$file","$destination/$file");
        }
    }
    closedir($dir_handle);
}

你在哪个平台上运行这个?我刚刚在windows上试用过,效果非常好。

为什么要在php中这样做?操作系统是为此而设计的:
exec(cp-source-dest)
这是一个基于php的网站,位于一个服务器上,除了通过ftp,我没有访问权限,所以我真的需要一个php解决方案删除
@
,这样您就可以看到实际的错误messages@Mogria:那附近还有其他系统吗?开玩笑吧,赢了就可以用拷贝了。在phmm中执行此操作仍然不明智奇怪删除@make no difference和no errors is display??