|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-06-28 11:32 UTC] oscar dot de dot lathouder at gmail dot com
Description: ------------ The recursive option of mkdir() creates wrong owners for created parents. Reproduce code: --------------- Executed file: -rw-rw-rw- 1 thisuser mygoup 5900 Jun 28 09:32 test.php saveLocation: /mnt/shared/ ls -al /mnt/shared/ drwxrwxrwx 1 thisuser mygroup 0 Jun 28 09:21 . drwxr-xr-x 5 root root 4096 Jun 23 15:11 .. (note: server is MS Windows 2000 server, executing server is Fedora Core 5. 'thisuser' has read/write permissions on server as well) Code: $saveLocation = /mnt/shared/1/2/3/ if (!file_exists($saveLocation) && !is_dir($saveLocation)) mkdir($saveLocation,0777,true); Expected result: ---------------- ls -al /mnt/shared/ drwxrwxrwx 1 thisuser mygroup 0 Jun 28 09:21 . drwxr-xr-x 5 root root 4096 Jun 23 15:11 .. drwxrwxrwx 1 thisuser mygroup 0 Jun 28 09:21 1 ls -al /mnt/shared/1/ drwxrwxrwx 1 thisuser mygroup 0 Jun 28 09:21 . drwxrwxrwx 1 thisuser mygroup 0 Jun 28 09:21 .. drwxrwxrwx 1 thisuser mygroup 0 Jun 28 09:21 2 ls -al /mnt/shared/1/2/ drwxrwxrwx 1 thisuser mygroup 0 Jun 28 09:21 . drwxrwxrwx 1 thisuser mygroup 0 Jun 28 09:21 .. drwxrwxrwx 1 thisuser mygroup 0 Jun 28 09:21 3 Actual result: -------------- ls -al /mnt/shared/ drwxrwxrwx 1 thisuser mygroup 0 Jun 28 2006 . drwxr-xr-x 5 root root 4096 Jun 23 15:11 .. drwxrwxrwx 1 root root 0 Jun 28 2006 1 ls -al /mnt/shared/1/ drwxrwxrwx 1 root root 0 Jun 28 2006 . drwxrwxrwx 1 thisuser mygroup 0 Jun 28 2006 .. Errorlog: [Wed Jun 28 10:58:43 2006] [error] [client xx.xx.xx.xx] PHP Warning: mkdir() [<a href='function.mkdir'>function.mkdir</a>]: Permission denied in /var/www/html/test.php on line 2, referer: http://xx.xx.xx.xx/test.php When I execute the same script again, it will create another directory (2), but exits with the same error. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 15:00:01 2025 UTC |
I'm not sure about the 'standard owner' created by PHP(which is 'root'), but the solution was found in using umask(). <?php $saveLocation= "/testdir/test1/test2/test4"; if (!is_dir($saveLocation)){ $oldumask = umask(0); mkdir($saveLocation,0666,true); umask($oldumask); } ?> Sorry.