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. Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
newb Posted July 12, 2009 Author Share Posted July 12, 2009 nvmd fixed Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.