Last active
October 27, 2015 02:20
-
-
Save mauriciogofas/635141546c82702b530f to your computer and use it in GitHub Desktop.
#PHP - copy all files (not recursive) in a directory to another
This file contains hidden or 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
<?php | |
$src = '/home/username/public_html/'; // Caminho absoluto da origem, mas tb pode ser um caminho relativo a pasta onde está sendo executado o script | |
$dst = 'beta/'; // Caminho relativo a pasta onde está sendo executado o script | |
$files = glob("/home/username/public_html/*.*"); // Nome global para os arquivos | |
foreach($files as $file){ | |
$file_to_go = str_replace($src,$dst,$file); | |
copy($file, $file_to_go); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment