Last active
January 18, 2019 08:41
-
-
Save melnikovslava2010/c8219c2fca67cb9804b4c2cb0418b2f2 to your computer and use it in GitHub Desktop.
Копирование папок и файлов
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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