Forum Moderators: coopster

Message Too Old, No Replies

Unable to remove folders created with mkdir()

Also unable to change permissions on them

         

dougmcc1

4:42 am on Oct 28, 2003 (gmt 0)

10+ Year Member



I'm using this code to create subdirectories:

$path="/home/lcdinwcy/public_html/$section/$newdirname";
$addeddir=mkdir($path, 0777)

Once they're created, I can't delete them. It says permission denied and the permission is set to 755. When I change it to 777 with my FTP client, it doesn't take effect. The permission is still set at 755 and I'm still unable to remove the folder.

I now have about 10 test folders I created that I can't delete.

Any ideas on how to delete them? Can I modify my code somehow to create subdirectories that I can delete?

Thanks.

PhraSEOlogy

5:02 am on Oct 28, 2003 (gmt 0)

10+ Year Member



Have you tried running the rmdir from within a script in the same way you created them?

NickCoons

6:24 am on Oct 28, 2003 (gmt 0)

10+ Year Member



dougmcc1,

<Once they're created, I can't delete them. It says permission denied and the permission is set to 755. When I change it to 777 with my FTP client, it doesn't take effect. The permission is still set at 755 and I'm still unable to remove the folder.>

I had a similar problem, and it was definately permissions. I suspect the same in your case.

The sub-directory you are creating has permissions 755, which means that everyone has read and execute permissions, but only the creator has access to write to the sub-directory. The creator, in this case, is whatever user the web server is running as. This is almost definately *not* the same user that you are logged in as through FTP. Since the web server created the sub-directory, you (logged in through FTP) cannot make modifications to the it, including removing it. Try removing it with the same user that created it, the web server, through your PHP script.

Also, and I may be wrong here, but I believe the permissions you set to the sub-directory are for the contents of the sub-directory, not the sub-directory itself. So even if you successfully create a sub-directory with permissions 777, that may mean that everyone has full access to the *contents* of the sub-directory, but the permissions on the sub-directory itself, I believe, are determined by the settings placed on the parent sub-directory, which are probably not set to 777.

dougmcc1

4:11 pm on Oct 30, 2003 (gmt 0)

10+ Year Member



Thanks Nick. Awesome post.