Page 1 of 1

rmdir permissions

Posted: Sat Mar 22, 2003 11:30 am
by bmark
I am new to PHP and have run into some problems with handling directories. I am using a Win2000 Adv Server System. I first create a directory with the following code:

mkdir("c:/inetpub/wwwcintrainc/images/$imagedir",0777);

where $imagedir is my new directory name.

When I come to delete this directory with:

rmdir("c:/inetpub/wwwcintrainc/images/$imagedir");

it tells me that I do not have permission to delete this directory.

CAN SOMEONE TELL ME WHAT I AM DOING WRONG????

I have messed with different permissions and changing the directory in IIS to no avail.

Posted: Sat Mar 22, 2003 11:41 am
by pootergeist
you know that windows based servers use opposite slashes?

C:dir\dir

and the *nix chmod shouldn't be needed on windows.

Posted: Sat Mar 22, 2003 5:29 pm
by lazy_yogi
from php.net :
Description
int rmdir ( string dirname)

Attempts to remove the directory named by dirname.
The directory must be empty, and the relevant permissions must permit this.
so you'll need a function like this :

Code: Select all

function deleteDir ($dir) {
      $d = opendir ("$dir");
      while ($file = readdir ($d)) {
            if ($file == ".." || $file == ".")
                  continue;
            elseif (is_dir ($dir."/".$file))
                  deleteDir($dir."/".$file);
            else
                  unlink($dir."/".$file);
      }
      closedir ($d);
      rmdir ("$dir");
}
and then call it :

Code: Select all

deleteDir("c:/inetpub/wwwcintrainc/images/$imagedir");

Dir is empty

Posted: Sun Mar 23, 2003 11:27 am
by bmark
I don't think this is going to work. I have not done anything with the directory just created and then tried to delete it. There is nothing in the directory. I believe this is a permission problem. I will try this and post back a resposne if it works.