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.
rmdir permissions
Moderator: General Moderators
-
pootergeist
- Forum Contributor
- Posts: 273
- Joined: Thu Feb 27, 2003 7:22 am
- Location: UK
from php.net :
and then call it :
so you'll need a function like this :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.
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");
}Code: Select all
deleteDir("c:/inetpub/wwwcintrainc/images/$imagedir");Dir is empty
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.