is_writable($dir) not working

2.1k views Asked by At

when I was working with thix thix ix all fine it ix showing all the subfolder and than subfolders of the subfolders

<?php

function listFolderFiles($dir){
    $Folders = scandir($dir);
    echo '<ol>';
    foreach($folders as $subFolders){
        if($subFolders != '.' && $subFolders != '..'){
             echo '<li>'.$subFolders;
             if(is_dir($dir.'/'.$subFolder)) listFolderFiles($dir.'/'.$subFolders);
             echo '</li>';
         }
    }

    echo '</ol>';
}

listFolderFiles('/home/');

?>

but when i changed the code a little bit to check whether any folder is writable than it gave me nothing neither an error nor shown the results.. at the line

if($subFolders != '.' && $subFolders != '..'){
                if(is_writable($subFolders)){
        echo '<li>'.$subFolders.' is witeable :) ';
1

There are 1 answers

3
Patrick Moore On BEST ANSWER

You're close, but missing the full file name. Need the $dir.'/'. part (the parent path):

if(is_writable($dir.'/'.$subFolders)){