Home > Backend Development > PHP Tutorial > Code example for copying directory and all files in php

Code example for copying directory and all files in php

WBOY
Release: 2016-07-25 08:59:04
Original
1022 people have browsed it
  1. /**
  2. * Copy directory function
  3. * @param $src source directory
  4. * @param $dst target directory
  5. */
  6. function recurse_copy($src,$dst) {
  7. $dir = opendir($src);
  8. @mkdir($dst);
  9. while(false !== ( $file = readdir($dir)) ) {
  10. if (( $file != '.' ) && ( $file != '..' )) {
  11. if ( is_dir($src . '/' . $file) ) {
  12. recurse_copy($src . '/' . $file,$dst . '/' . $file);
  13. }
  14. else {
  15. copy($src . '/' . $file,$dst . '/' . $file);
  16. }
  17. }//by bbs.it-home.org
  18. }
  19. closedir($dir);
  20. }
  21. ?>
复制代码


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template