d22552000 Posted August 13, 2007 Share Posted August 13, 2007 How do I copy an entire folder, subfolders and Files? Please attach or reply with a script and Thank You. Quote Link to comment https://forums.phpfreaks.com/topic/64761-solved-repost-copy-dir/ Share on other sites More sharing options...
dbo Posted August 13, 2007 Share Posted August 13, 2007 Well I'll be very surprised if anyone attempts your request since you're breaking a rule by reposting and then asking someone to write code for you. If you want help show some code where you made an attempt and we might help you. No one is here to do your work for you. Quote Link to comment https://forums.phpfreaks.com/topic/64761-solved-repost-copy-dir/#findComment-323023 Share on other sites More sharing options...
hitman6003 Posted August 13, 2007 Share Posted August 13, 2007 Please attach or reply with a script and Thank You. If you want someone to write something for you post in the freelancer's forum. http://www.phpfreaks.com/forums/index.php/board,8.0.html Quote Link to comment https://forums.phpfreaks.com/topic/64761-solved-repost-copy-dir/#findComment-323024 Share on other sites More sharing options...
uwannadonkey Posted August 13, 2007 Share Posted August 13, 2007 well, i googled, and found this. ANY help? SkyEye 07-Oct-2006 10:21 <?php // A function to copy files from one directory to another one, including subdirectories and // nonexisting or newer files. Function returns number of files copied. // This function is PHP implementation of Windows xcopy A:\dir1\* B:\dir2 /D /E /F /H /R /Y // Syntaxis: [$number =] dircopy($sourcedirectory, $destinationdirectory [, $verbose]); // Example: $num = dircopy('A:\dir1', 'B:\dir2', 1); function dircopy($srcdir, $dstdir, $verbose = false) { $num = 0; if(!is_dir($dstdir)) mkdir($dstdir); if($curdir = opendir($srcdir)) { while($file = readdir($curdir)) { if($file != '.' && $file != '..') { $srcfile = $srcdir . '\\' . $file; $dstfile = $dstdir . '\\' . $file; if(is_file($srcfile)) { if(is_file($dstfile)) $ow = filemtime($srcfile) - filemtime($dstfile); else $ow = 1; if($ow > 0) { if($verbose) echo "Copying '$srcfile' to '$dstfile'..."; if(copy($srcfile, $dstfile)) { touch($dstfile, filemtime($srcfile)); $num++; if($verbose) echo "OK\n"; } else echo "Error: File '$srcfile' could not be copied!\n"; } } else if(is_dir($srcfile)) { $num += dircopy($srcfile, $dstfile, $verbose); } } } closedir($curdir); } return $num; } ?> and your a naughty kid for breaking rules Quote Link to comment https://forums.phpfreaks.com/topic/64761-solved-repost-copy-dir/#findComment-323025 Share on other sites More sharing options...
d22552000 Posted August 14, 2007 Author Share Posted August 14, 2007 lol you guys are hilarious. I love how on eveyr forum I go tom, im always the one that they decide... "Ya.. well.. many people do it, but.. this guy did it last." it gets on my nerves. I posted this as a HOW TO copy dirs originally, and I thought it was solved.. but no. so instead of double posting and bumping (two other rules) I posted it again. I wish php came with a function for this -,- maybe CDDIR lol? I am trying the code you gave me "uwannadonkey"... hope it works. IT WOKRS YAYA THANKS Quote Link to comment https://forums.phpfreaks.com/topic/64761-solved-repost-copy-dir/#findComment-323040 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.