Reputation: 1094
just i'm trying to copy all file source to destination and then remove all file from source in php.
here is my code:
function rcopy($src, $dst) {
if (is_dir($src)) {
$files = scandir($src);
foreach ($files as $file) {
if ($file != "." && $file != "..")
rcopy("$src/$file", "$dst/$file");
}
array_map('unlink', glob($src."/*"));
} else if (file_exists($src)) {
copy($src, $dst);
}
}
copy working well but file not deleted from source. please help
Upvotes: 1
Views: 732
Reputation: 16307
$files = scandir($src);
foreach ($files as $file) {
if ($file != "." && $file != "..") {
rcopy("$src/$file", "$dst/$file");
unlink("$src/$file");
}
}
Upvotes: 1