Good day,

I looked over the forums here and I found many related threads to permission denied errors but none I looked adressed a solution for my problem.

I run EasyPHP 1.7 on a Windows 2000 box. It has Apache 1.3.27 PHP 4.3.3.

I can create directories to store extracted zip files. Comes a time I want to delete these files and the directories. I can unlink the files but I can't remove the directories.

[Mon Jan 05 14:49:47 2004] [error] PHP Warning: rmdir(D:\moodledata/2/moddata/scorm/ADL_Maritime_Navigation): Permission denied in d:\program files\easyphp1-7\www\moodle\mod\scorm\lib.php on line 169

Yes, the directories I want to remove are empty.

function scorm_delete_files($directory)
{
    if (is_dir($directory))
    {
        $handle=opendir($directory);
        while (($file = readdir($handle)) != '')
        {
             if ($file != "." && $file != "..")
             {
                   if (!is_dir($directory."/".$file))
                        unlink($directory."/".$file);
                   else
                        scorm_delete_files($directory."/".$file);
             }
        }			
        rmdir($directory);
    }
}

Sorry for the formating by the way, I have C++ code writing habits!

chmod is set to 0750 for all directories I create.

I presume it's a configuration problem with Apache. I'm having big time trouble finding CLEAR configuration tips of httpd.conf

Anyone can help?

Thanks! 🙂

    My guess would be the user Apache/PHP are running as does not have full access to the upper level directory. My 2nd guess would be Windows has taken it upon itself to lock the directory because it feels its in use (you could test this theory by trying to delete it from Explorer or the command prompt).

      AstroTeg, can you give me infos on how I could give full access to the user Apache/PHP for upper level directory?

      As for your 2nd guess, I'm able to delete the directory with Explorer or the command prompt.

        I think you'll need to check the docs to find out who Apache runs as on a Win box (I don't believe it runs as "everyone" but runs as another user with the computer name in it - or am I thinking of IIS? - basically, I don't know). Which ever user it is, you'll want to navigate to that directory and right click and go to security (or find the security tab and its settings). You should see a list of users. Check if the Apache user is in there. If so, make sure it has some permissions (might try giving it full access and then test it - if it works, then back off some of the permissions and try again). If the user isn't there, then you'll want to add the Apache user and then set its permissions.

          Ok, my directory has NTFS permissions for Everyone, me as an admin and System. I'll try to find the Apache user or infos about it.

            9 months later

            apache runs for the user youre logged on with.... since its installed as service (under win2000/xp)

            If youre running a server dedicated.... then just login as administrator or highest user you have access too.

            Power user (win2000 only i think) should work too!

            Also i noticed you dont close the dir in your snippet posted in post#1... maybe that solves things?

              Just to tell you all that the problem of access denied with rmdir() has a very easy solution in this case.

              In the 1st thread, you can see in the code that there's an opendir command. Before attempting to remove the directory, you have to close it, which my code lacks.

              A very newbie mistake there... I was bit ashamed to have spent so much time digging way too far for this one!

                lol well atleast you solved it 🙂

                but i suggested closing the dir aswell :p

                  Write a Reply...