递归复制&查看文件夹下的指定后缀的文件

Posted Basu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了递归复制&查看文件夹下的指定后缀的文件相关的知识,希望对你有一定的参考价值。

<?php
    header("content-type:text/html;charset=utf8"); 
    set_time_limit(0); 
    $dir = "d:\\";
    function show ($dir){
        $handle = @opendir($dir);
        echo "<ul>";
         while($file = @readdir($handle)){
             if($file == "."||$file == "..")
                 continue;
             
             if(is_dir("$dir/$file")){
                 show("$dir/$file");
             }else{
                 if(pathinfo("$dir/$file",PATHINFO_EXTENSION) == "pdf"){
                     // copy("$dir/$file","./pdf/$file");
                     echo "<li>".iconv(‘gbk‘,‘utf-8‘,$file)."</li>";
                 }
             }
         }
        echo "</ul>";
    }
    show($dir);
    

 

以上是关于递归复制&查看文件夹下的指定后缀的文件的主要内容,如果未能解决你的问题,请参考以下文章