• <small id='U4YFR'></small><noframes id='U4YFR'>

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

        <legend id='U4YFR'><style id='U4YFR'><dir id='U4YFR'><q id='U4YFR'></q></dir></style></legend>
        <tfoot id='U4YFR'></tfoot>
      1. 使用 php 删除所有文件、文件夹及其子文件夹

        Remove all files, folders and their subfolders with php(使用 php 删除所有文件、文件夹及其子文件夹)
        <i id='oHiRc'><tr id='oHiRc'><dt id='oHiRc'><q id='oHiRc'><span id='oHiRc'><b id='oHiRc'><form id='oHiRc'><ins id='oHiRc'></ins><ul id='oHiRc'></ul><sub id='oHiRc'></sub></form><legend id='oHiRc'></legend><bdo id='oHiRc'><pre id='oHiRc'><center id='oHiRc'></center></pre></bdo></b><th id='oHiRc'></th></span></q></dt></tr></i><div id='oHiRc'><tfoot id='oHiRc'></tfoot><dl id='oHiRc'><fieldset id='oHiRc'></fieldset></dl></div>

      2. <legend id='oHiRc'><style id='oHiRc'><dir id='oHiRc'><q id='oHiRc'></q></dir></style></legend>

          • <bdo id='oHiRc'></bdo><ul id='oHiRc'></ul>
            <tfoot id='oHiRc'></tfoot>

                  <tbody id='oHiRc'></tbody>

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

                  本文介绍了使用 php 删除所有文件、文件夹及其子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要一个脚本,它可以删除整个目录及其所有子文件夹、文件等.我尝试使用这个功能,几个月前我在互联网上找到了这个功能,但它不能完全工作.

                  I need a script which can remove a whole directory with all their subfolders, files and etc. I tried with this function which I found in internet before few months ago but it not work completely.

                  function deleteFile($dir) {
                      if(substr($dir, strlen($dir)-1, 1) != '/') { 
                          $dir .= '/'; 
                      }
                      if($handle = opendir($dir)) { 
                          while($obj = readdir($handle)) { 
                              if($obj != '.' && $obj != '..') { 
                                  if(is_dir($dir.$obj)) { 
                                      if(!deleteFile($dir.$obj)) {
                                          echo $dir.$obj."<br />";
                                          return false;
                                      }
                                  }
                                  elseif(is_file($dir.$obj)) { 
                                      if(!unlink($dir.$obj)) {
                                          echo $dir.$obj."<br />";
                                          return false;
                                      }
                                  }
                              }
                          }
                          closedir($handle); 
                          if(!@rmdir($dir)) {
                              echo $dir.'<br />';
                              return false;
                          }
                          return true;
                      }
                      return true;
                  }
                  

                  为了测试,我使用了 prestashop 的解压存档,我尝试删除解压存档的文件夹,但它不起作用.

                  For the test I use a unpacked archive of prestashop and I try to delete the folder where archive is unpacked but it doesn't work.

                  /home/***/public_html/prestashop/img/p/3/
                  /home/***/public_html/prestashop/img/p/3
                  /home/***/public_html/prestashop/img/p
                  /home/***/public_html/prestashop/img
                  

                  这些是问题文件夹.我第一次想 - 可能是文件的 chmod 有问题"但是当我测试所有文件的 chmod 权限 755(之后是 777) - 结果是一样的.

                  These are the problem folders. At the first time I think - "May is a problem with the chmod of the files" but when I test with all files chmod permission 755 (after that with 777) - the result was the same.

                  推荐答案

                  <?php
                    function rrmdir($dir) {
                    if (is_dir($dir)) {
                      $objects = scandir($dir);
                      foreach ($objects as $object) {
                        if ($object != "." && $object != "..") {
                          if (filetype($dir."/".$object) == "dir") 
                             rrmdir($dir."/".$object); 
                          else unlink   ($dir."/".$object);
                        }
                      }
                      reset($objects);
                      rmdir($dir);
                    }
                   }
                  ?>
                  

                  从 php.net

                  对我来说很好

                  这篇关于使用 php 删除所有文件、文件夹及其子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)

                      <tbody id='j4rkk'></tbody>

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

                  1. <tfoot id='j4rkk'></tfoot>

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