• <tfoot id='R5WG6'></tfoot>
  • <legend id='R5WG6'><style id='R5WG6'><dir id='R5WG6'><q id='R5WG6'></q></dir></style></legend>
  • <i id='R5WG6'><tr id='R5WG6'><dt id='R5WG6'><q id='R5WG6'><span id='R5WG6'><b id='R5WG6'><form id='R5WG6'><ins id='R5WG6'></ins><ul id='R5WG6'></ul><sub id='R5WG6'></sub></form><legend id='R5WG6'></legend><bdo id='R5WG6'><pre id='R5WG6'><center id='R5WG6'></center></pre></bdo></b><th id='R5WG6'></th></span></q></dt></tr></i><div id='R5WG6'><tfoot id='R5WG6'></tfoot><dl id='R5WG6'><fieldset id='R5WG6'></fieldset></dl></div>

      <small id='R5WG6'></small><noframes id='R5WG6'>

        • <bdo id='R5WG6'></bdo><ul id='R5WG6'></ul>

        目录的递归复制

        Recursive Copy of Directory(目录的递归复制)

            <tbody id='d5qiO'></tbody>
            <i id='d5qiO'><tr id='d5qiO'><dt id='d5qiO'><q id='d5qiO'><span id='d5qiO'><b id='d5qiO'><form id='d5qiO'><ins id='d5qiO'></ins><ul id='d5qiO'></ul><sub id='d5qiO'></sub></form><legend id='d5qiO'></legend><bdo id='d5qiO'><pre id='d5qiO'><center id='d5qiO'></center></pre></bdo></b><th id='d5qiO'></th></span></q></dt></tr></i><div id='d5qiO'><tfoot id='d5qiO'></tfoot><dl id='d5qiO'><fieldset id='d5qiO'></fieldset></dl></div>
          • <legend id='d5qiO'><style id='d5qiO'><dir id='d5qiO'><q id='d5qiO'></q></dir></style></legend>

              • <tfoot id='d5qiO'></tfoot>

                <small id='d5qiO'></small><noframes id='d5qiO'>

                • <bdo id='d5qiO'></bdo><ul id='d5qiO'></ul>
                • 本文介绍了目录的递归复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

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

                  On my old VPS I was using the following code to copy the files and directories within a directory to a new directory that was created after the user submitted their form.

                  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 之间会发生什么变化?

                  However now on my new VPS it will only create the main directory, but will not copy any of the files to it. I don't understand what could have changed between the 2 VPS's?

                  推荐答案

                  试试这个:

                  $source = "dir/dir/dir";
                  $dest= "dest/dir";
                  
                  mkdir($dest, 0755);
                  foreach (
                   $iterator = new RecursiveIteratorIterator(
                    new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
                    RecursiveIteratorIterator::SELF_FIRST) as $item
                  ) {
                    if ($item->isDir()) {
                      mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathname());
                    } else {
                      copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathname());
                    }
                  }
                  

                  迭代器遍历所有文件夹和子文件夹,并将文件从 $source 复制到 $dest

                  Iterator iterate through all folders and subfolders and make copy of files from $source to $dest

                  这篇关于目录的递归复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <small id='8jHPS'></small><noframes id='8jHPS'>

                    <bdo id='8jHPS'></bdo><ul id='8jHPS'></ul>

                      <tfoot id='8jHPS'></tfoot>
                      1. <i id='8jHPS'><tr id='8jHPS'><dt id='8jHPS'><q id='8jHPS'><span id='8jHPS'><b id='8jHPS'><form id='8jHPS'><ins id='8jHPS'></ins><ul id='8jHPS'></ul><sub id='8jHPS'></sub></form><legend id='8jHPS'></legend><bdo id='8jHPS'><pre id='8jHPS'><center id='8jHPS'></center></pre></bdo></b><th id='8jHPS'></th></span></q></dt></tr></i><div id='8jHPS'><tfoot id='8jHPS'></tfoot><dl id='8jHPS'><fieldset id='8jHPS'></fieldset></dl></div>

                          <legend id='8jHPS'><style id='8jHPS'><dir id='8jHPS'><q id='8jHPS'></q></dir></style></legend>
                            <tbody id='8jHPS'></tbody>