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 Link to comment https://forums.phpfreaks.com/topic/126070-copy-folder-problem/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.