rmdir permissions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bmark
Forum Newbie
Posts: 9
Joined: Mon Feb 17, 2003 12:19 pm

rmdir permissions

Post 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.
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

you know that windows based servers use opposite slashes?

C:dir\dir

and the *nix chmod shouldn't be needed on windows.
User avatar
lazy_yogi
Forum Contributor
Posts: 243
Joined: Fri Jan 24, 2003 3:27 am

Post 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");
bmark
Forum Newbie
Posts: 9
Joined: Mon Feb 17, 2003 12:19 pm

Dir is empty

Post 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.
Post Reply