mkdir permissions help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • banning
    New Member
    • Aug 2007
    • 42

    mkdir permissions help

    Code:
    while($row = mysql_fetch_array($getID)){
    		$id=$row['id'];
    		$dir='../picture_library/floorplans/'.$id;
    		mkdir($dir,0777);
    		chmod($dir,0777);
    	}
    ok this is really starting to kill me... i've bee on this for an hour now surfing the net trying to find a solution. I am using a test server that i run on my computer to build sites and then upload (not sure if that will have any bearing).

    anyway what im trying to do is OBVIOUSLY set permissions to this directory i just created BECAUSE... later on there is an option to delete...

    Code:
    unlink('../picture_library/floorplans/'.$id.'');
    however everytime i goto delete it says i don't have permissions... and clearly when i created the directory i set the permissions (at least im sure i did). Anyway any and all help would be had. Thanks guys.

    i just tried this i dont know if it will help but i ran

    Code:
    echo substr(sprintf("%o",fileperms('../picture_library/floorplans/'.$id.'')),-4);
    and got 0777

    ok so now i just ran

    Code:
    is_executable();
    is_readable();
    is_writeable();
    and apparently the file is readable and writeable HOWEVER it is not executable... how can that be if it says the permissions are 0777
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by banning
    Code:
    while($row = mysql_fetch_array($getID)){
    		$id=$row['id'];
    		$dir='../picture_library/floorplans/'.$id;
    		mkdir($dir,0777);
    		chmod($dir,0777);
    	}
    ok this is really starting to kill me... i've bee on this for an hour now surfing the net trying to find a solution. I am using a test server that i run on my computer to build sites and then upload (not sure if that will have any bearing).

    anyway what im trying to do is OBVIOUSLY set permissions to this directory i just created BECAUSE... later on there is an option to delete...

    Code:
    unlink('../picture_library/floorplans/'.$id.'');
    however everytime i goto delete it says i don't have permissions... and clearly when i created the directory i set the permissions (at least im sure i did). Anyway any and all help would be had. Thanks guys.

    i just tried this i dont know if it will help but i ran

    Code:
    echo substr(sprintf("%o",fileperms('../picture_library/floorplans/'.$id.'')),-4);
    and got 0777

    ok so now i just ran

    Code:
    is_executable();
    is_readable();
    is_writeable();
    and apparently the file is readable and writeable HOWEVER it is not executable... how can that be if it says the permissions are 0777
    files
    When using unlink() the script that executes it must be in the same directory as the poor file being deleted.

    directories
    Try using rm_dir() to remove directories
    :)

    Comment

    • banning
      New Member
      • Aug 2007
      • 42

      #3
      Originally posted by markusn00b
      files
      When using unlink() the script that executes it must be in the same directory as the poor file being deleted.

      directories
      Try using rm_dir() to remove directories
      :)
      LOL the poor file haha... thats good stuff... but rmdir(); only deletes a directory that is empty. However i have found a solution on another forum, i haven't tried it yet but i'll go ahead and post it.

      Code:
      function RecursiveFolderDelete ( $folderPath ){
          if ( is_dir ( $folderPath ) ){
              foreach ( scandir ( $folderPath )  as $value ){
                  if ( $value != "." && $value != ".." ){
                      $value = $folderPath . "/" . $value;
                      if ( is_dir ( $value ) ){
                          FolderDelete ( $value );
                      }elseif ( is_file ( $value ) ){
                          @unlink ( $value );
                      }
                  }
              }
              return rmdir ( $folderPath );
          }else{
              return FALSE;
          }
      }

      Comment

      Working...