bobcooper Posted September 27, 2008 Share Posted September 27, 2008 Hi there, I am having a problem copying a folder and its sub folders. When I try the script on my computer it works fine, but when I upload it to my website it only creates a new folder, it does not copy the files. I was thinking it might be something to do with permissions so added chmod settings but that does not work either. Here is the code: <?php $dir = "../"; $count = 0; if(is_dir($dir)) { if($handle = opendir($dir)) { while(($file = readdir($handle)) !== false) { if($file != '.' && $file != '..' && $file != 'upload'){ $count++; } } closedir($handle); } } $issueNo = $count + 1; $destination = $_SERVER['DOCUMENT_ROOT']."/newsletter/issue_".$issueNo; $source = $_SERVER['DOCUMENT_ROOT']."/newsletter/issue_1"; function full_copy( $source, $target ) { if ( is_dir( $source ) ) { @mkdir( $target ); chmod($target, 0777); $d = dir( $source ); while ( FALSE !== ( $entry = $d->read() ) ) { if ( $entry == '.' || $entry == '..' ) { continue; } $Entry = $source . '/' . $entry; if ( is_dir( $Entry ) ) { full_copy( $Entry, $target . '/' . $entry ); continue; } copy( $Entry, $target . '/' . $entry ); } $d->close(); }else { copy( $source, $target ); } } full_copy($source, $destination); ?> Your help would be greatly appreciated, Thanks, Bob www.bobcooper.org.uk 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.