newb Posted July 12, 2009 Share Posted July 12, 2009 i need a function that can copy a directory and all subdirectories and files inside of it. please help thasnks. Link to comment https://forums.phpfreaks.com/topic/165730-solved-php-copy-directories/ Share on other sites More sharing options...
newb Posted July 12, 2009 Author Share Posted July 12, 2009 btw i am using this function atm function copyr($source, $dest){ // Simple copy for a file if (is_file($source)) { $c = copy($source, $dest); chmod($dest, 0777); return $c; } // Make destination directory if (!is_dir($dest)) { $oldumask = umask(0); mkdir($dest, 0755); umask($oldumask); } // Loop through the folder $dir = dir($source); while (false !== $entry = $dir->read()) { // Skip pointers if ($entry == "." || $entry == "..") { continue; } // Deep copy directories if ($dest !== "$source/$entry") { copyr("$source/$entry", "$dest/$entry"); } } // Clean up $dir->close(); return true; } copyr('/home/www/www.domain.com/test/','/home/www/www.domain.com/web/test/'); but it is only creating the directory in the destination not copying all the subdirectories or files. Link to comment https://forums.phpfreaks.com/topic/165730-solved-php-copy-directories/#findComment-874260 Share on other sites More sharing options...
newb Posted July 12, 2009 Author Share Posted July 12, 2009 wow just realized that the php copy function isnt working at all for some reason.. might but part of the problem...anybody have any idea why? Link to comment https://forums.phpfreaks.com/topic/165730-solved-php-copy-directories/#findComment-874263 Share on other sites More sharing options...
newb Posted July 12, 2009 Author Share Posted July 12, 2009 nvmd fixed Link to comment https://forums.phpfreaks.com/topic/165730-solved-php-copy-directories/#findComment-874273 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.