Removing created dirs

I am creating a ftp-like program in php, so that i can do stuff when i dont have a ftp program (only listing, creating/removing dirs, upload/remove files). that is restricted in a given directory.

i got the listing completely done now, and working on the Create Folder function, should sound easy, and it doz work, but, when i create a folder inside a created folder (both done with mdir($pathNewFolder, 0777)) i cant delete those 2 folders anymore… it says:

[13:31:16] 257 “/public_html/school/downloads”
[13:31:16] RMD /public_html/school/downloads/TEST/TEST
[13:31:16] 550 Remove directory operation failed.
[13:31:16] RMD /public_html/school/downloads/TEST
[13:31:16] 550 Remove directory operation failed.

ok, could, so i make sure the folder DOWNLOADS has chmod 777, still the same message

so, i tried the other option, with SSH (using putty)

[rvgate@astrepitum TEST]$ rmdir TEST/
rmdir: `TEST/': Permission denied

ok, now make sure the chmod is good:

[rvgate@astrepitum TEST]$ chmod 777 TEST/
chmod: changing permissions of `TEST/': Operation not permitted

so, im kinda stuck here, and i dont have root acces.
if someone could give me a solution, please :slight_smile:

found it:

If you’re on a shared *nix server, a directory created through mkdir() will not be assigned to you, but to the user that your host’s server or php process is running under, usually ‘nobody’, ‘apache’ or ‘httpd’.

In practice, this means that you can create directories, even add files to them, but you can’t delete the directory or its contents nor change permissions.

It is therefore advised to create directories through PHP’s FTP API.

And the function this guy wrote


// create directory through FTP connection
function FtpMkdir($path, $newDir) {
  
       $server='ftp.yourserver.com'; // ftp server
       $connection = ftp_connect($ftp_server); // connection
  
 
       // login to ftp server
       $user = "me";
       $pass = "password";
       $result = ftp_login($connection, $user, $pass);

   // check if connection was made
     if ((!$connection) || (!$result)) {
       return false;
       exit();
       } else {
         ftp_chdir($connection, $path); // go to destination dir
       if(ftp_mkdir($connection,$newDir)) { // create directory
           return $newDir;
       } else {
           return false;       
       }
   ftp_close($conn_id); // close connection
   }

}