1

I have a small script that create a directory for a user who registers an account on my site. This director is used to store images in that they upload.

When I use mkdir() with permissions of 0777, the directory is created under the users name, but the permissions stay as 0755.

I have tried a few different ways to do this, as follows;

$path = path/to/directory/and/filename

$old = umask(0);
mkdir($path,0777);
umask($old);

also;

$path = path/to/directory/and/filename/

mkdir($path, 0777, true);

also;

$path = path/to/directory/and/filename/

mkdir($path);
chmod($path,0777);

When I create a directory myself in the ftp client the owner and group is me, but when the php script created them, it has the owner and group of apache/apache'. I don't think if this is anything to do with it?

I have spent a good while trying to figure this out, and I have also spent a fair amount of time searching on this forum and others, so any help would be amazing!

If there is any other information required, I can provide. Thanks!

0 Answers0