On Wednesday 24 July 2002 11:12, Roger Lewis wrote:
> I'm trying to learn to create a directory in php, and from everything I've
> read I created this simple test that I put into the file add_user_dir.php.
> Unfortunately I can't get it to work.  I am getting the error message:
>
> Warning: MkDir failed (Permission denied) in
> /home/sites/home/users/demo/web/Admin/add_user_dir.php on line 20.
>
> Obviously, it has something to do with permissions.  I have chmod for the
> directory 'userforum' set to 0777.  I tried playing around with umask, and
> changing the chmod, but I can't get anything to work.

[snip]

> <?php
> $dirpath = "/home/sites/home/users/demodocs/web/userforum" . $username;
> mkdir($dirpath, 0777);
> ?>

Assuming $username is 'tom', are you trying to create:

a)  /home/sites/home/users/demodocs/web/userforumtom

or:

b)  /home/sites/home/users/demodocs/web/userforum/tom

Your code is trying to do (a). In any case whatever you're trying to do, you
need both the following:

i) Have execute permissions ('x') on all the directories in the path leading
down to where you wish to create your directory

ii) Have write permission ('w') on the directory in which you are creating
your directory



Jason and TechSupport,

Jeeze, do I feel stupid.  One slash and that's all it took.  Thanks much.

Re the permissions, I have userforum set to 0777.  php creates the new
directory as 0775.  Presumably this is because of the effect of umask,
right?
When I upload files to the new directory using php uploading script, they go
in as 0600, with owner - httpd, and group - root.  (The owner/group on my
machine is httpd/httpd).  I can link to and read the files on the browser OK
so I'm happy.  Are there any security issues I should be concerned with
here.

Thanks again, Roger Lewis

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to