just need to know where i put the destination directory and source? i dont see where it defines $source and $dest
thanks 🙂
<?php
/**
Copy a file, or a folder and its contents
@author Aidan Lister <aidan@php.net>
@version 1.0.0
@ string $source The source
@ string $dest The destination
@return bool Returns true on success, false on failure
/
function copyr($source, $dest)
{
// Simple copy for a file
if (is_file($source)) {
return copy($source, $dest);
}
// Make destination directory
if (!is_dir($dest)) {
mkdir($dest);
}
// Loop through the folder
$dir = dir($source);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Deep copy directories
if (is_dir("$source/$entry") && ($dest !== "$source/$entry")) {
copyr("$source/$entry", "$dest/$entry");
} else {
copy("$source/$entry", "$dest/$entry");
}
}
// Clean up
$dir->close();
return true;
}
?>