SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question chmod function not working on folders

    Hello,

    Can anyone tell me why chmod is only working on files, not folders and how I can change the mode of folders?

    Thanks.

  2. #2
    SitePoint Member aboys's Avatar
    Join Date
    Aug 2004
    Location
    China
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    chmod --help

    -R

  3. #3
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Huh?

  4. #4
    SitePoint Member aboys's Avatar
    Join Date
    Aug 2004
    Location
    China
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    chmod is change one file or fodler,if you want change more files rewrite the chmod function

    Examplde

    <?php

    function chmod_R($path, $filemode) {
    if (!is_dir($path))
    return chmod($path, $filemode);

    $dh = opendir($path);
    while ($file = readdir($dh)) {
    if($file != '.' && $file != '..') {
    $fullpath = $path.'/'.$file;
    if(!is_dir($fullpath)) {
    if (!chmod($fullpath, $filemode))
    return FALSE;
    } else {
    if (!chmod_R($fullpath, $filemode))
    return FALSE;
    }
    }
    }

    closedir($dh);

    if(chmod($path, $filemode))
    return TRUE;
    else
    return FALSE;
    }
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •