1

I would like to do a script in order to delete the contents of a file in php.

I have this :

<?php

class DelShell extends AppShell {


    public function main() { 
        $target = WWW_ROOT . DS . "pdf" ;

        $dir_iterator = new RecursiveDirectoryIterator($target);

        $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::CHILD_FIRST);

        foreach($iterator as $fichier){
            $fichier->isDir() ? rmdir($fichier) : unlink($fichier);
        }

        unlink($target);



    }

}

It's work but I have some problems : I have "Warning" with the rmdir .

Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95

0 Answers0