Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save melnikovslava2010/c8219c2fca67cb9804b4c2cb0418b2f2 to your computer and use it in GitHub Desktop.
Save melnikovslava2010/c8219c2fca67cb9804b4c2cb0418b2f2 to your computer and use it in GitHub Desktop.
Копирование папок и файлов
$ser = $_SERVER['DOCUMENT_ROOT'] . '/carparts';
$des = $_SERVER['DOCUMENT_ROOT'] . '/Admin';
copydirect($ser, $des, 1);
function copydirect($source, $dest, $over = false)
{
if (!is_dir($dest))
mkdir($dest);
if ($handle = opendir($source)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
$path = $source . '/' . $file;
if (is_file($path)) {
if (!is_file($dest . '/' . $file || $over))
if (!@copy($path, $dest . '/' . $file)) {
echo "('.$path.') Ошибка!!! ";
}
} elseif (is_dir($path)) {
if (!is_dir($dest . '/' . $file))
mkdir($dest . '/' . $file);
copydirect($path, $dest . '/' . $file, $over);
}
}
}
closedir($handle);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment