how to automatically extract all rar files recursively from a top directory in gmail

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hyungKim
    New Member
    • Jan 2013
    • 6

    how to automatically extract all rar files recursively from a top directory in gmail

    Code:
    <?php
    function scanDirectories($rootDir, $allowext, $allData=array()){
        $dirContent = scandir($rootDir);
        foreach($dirContent as $key => $content){
            $path = $rootDir.'/'.$content;
         $ext = substr($content, strrpos($content, '') + 1);
          if(in_array($ext, $allowext)) {
                if(is_file($path) && is_readable($path)){
                    $allData[] = $path;}
                elseif(is_dir($path) && is_readable($path)) {
                    // recursive callback to open new    directory
              $allData = scanDirectories($path, $allData);
                }    } }
        return $allData;}
    $rootDir = "www";
    $allowext = array("zip","rar","html");
    $files_array = scanDirectories($rootDir,$allowext);
    print_r($files_array);
    ?>
    ...ERROR IS:
    Warning: scandir(www,www ) [function.scandi r]: The system cannot find the file specified. (code: 2) in C:\Zend\Apache2 \htdocs\CSV\exa mple.php on line 4

    Warning: scandir(www) [function.scandi r]: failed to open dir: No such file or directory in C:\Zend\Apache2 \htdocs\CSV\exa mple.php on line 4

    Warning: scandir() [function.scandi r]: (errno 2): No such file or directory in C:\Zend\Apache2 \htdocs\CSV\exa mple.php on line 4

    Warning: Invalid argument supplied for foreach() in C:\Zend\Apache2 \htdocs\CSV\exa mple.php on line 5
    Array ( )





    please help ......:'(
    Last edited by acoder; Jan 13 '13, 09:32 PM. Reason: Please use [code][/code] tags when posting code.
Working...