2
<?php
$iterator = new RecursiveIteratorIterator(
                new RecursiveDirectoryIterator('./'), 
            RecursiveIteratorIterator::SELF_FIRST);

foreach($iterator as $file) {
    if($file->isDir()) {
        echo "\n" . strtoupper($file->getRealpath()), PHP_EOL;
    }
}
?>

The above is what I have so far. I am looking to go through dirs and also sub-dirs and see which ones are write-able.

4

1 回答 1

0

您是否尝试过使用 isWritable() 方法?

<?php
$iterator = new RecursiveIteratorIterator(
                new RecursiveDirectoryIterator('./'), 
            RecursiveIteratorIterator::SELF_FIRST);

foreach($iterator as $file) {
    if($file->isDir()) {
        echo "\n" . strtoupper($file->getRealpath()), PHP_EOL;
        if($file->isWritable()) {
            echo "directory is writable\n";
        }
    }

}
?>

http://www.php.net/manual/en/splfileinfo.iswritable.php

于 2013-08-14T23:27:38.863 回答