function copy folder และทุกไฟล์ที่อยู่ใน folder

function copydir($source,$destination){
        if(!file_exists($destination)){
            mkdir($destination, 01777); // so you get the sticky bit set
        }

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

Leave a comment

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Your email is never shared. Required fields are marked *