Skip to content

Instantly share code, notes, and snippets.

@mauriciogofas
Last active October 27, 2015 02:20
Show Gist options
  • Save mauriciogofas/635141546c82702b530f to your computer and use it in GitHub Desktop.
Save mauriciogofas/635141546c82702b530f to your computer and use it in GitHub Desktop.
#PHP - copy all files (not recursive) in a directory to another
<?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