首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >目录的递归副本

目录的递归副本
EN

Stack Overflow用户
提问于 2011-04-19 03:25:16
回答 12查看 51.8K关注 0票数 25

在我的旧VPS上,我使用以下代码将目录中的文件和目录复制到一个新目录中,该目录是在用户提交表单后创建的。

function copyr($source, $dest)
{
   // Simple copy for a file
   if (is_file($source)) {
      return copy($source, $dest);
   }

   // Make destination directory
   if (!is_dir($dest)) {
      mkdir($dest);
      $company = ($_POST['company']);
   }

   // Loop through the folder
   $dir = dir($source);
   while (false !== $entry = $dir->read()) {
      // Skip pointers
      if ($entry == '.' || $entry == '..') {
         continue;
      }

      // Deep copy directories
      if ($dest !== "$source/$entry") {
         copyr("$source/$entry", "$dest/$entry");
      }
   }

   // Clean up
   $dir->close();
   return true;
}

copyr('Template/MemberPages', "Members/$company")

然而,现在在我的新VPS上,它将只创建主目录,但不会将任何文件复制到其中。我不明白两个VPS之间会发生什么变化?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5707806

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档