umask() and chmod()

From: Date: Thu, 15 Apr 2004 15:26:25 +0000
Subject: umask() and chmod()
Groups: php.general 
Request: Send a blank email to php-general+get-183473@lists.php.net to get a copy of this message
Hi, all -- When I move_uploaded_file() a file into place, I want to give it the correct permissions; by default they are 600 (rw-/---/--). I already have the umask set correctly for any given situation in anticipation of creating directories, and that works for creating files from scratch, but chmod() needs a permissions setting rather than a umask. The challenge is in representing this as octal. With some mucking around I was able to print $u = decoct(umask()) ; $m = 0777 ; $r = decoct($m) - $u ; print "The setting is $r\n" ; and get The setting is 664 when umask returns 113. All is great, right? Well, no... I need to convert that 664 octal value into an octal representation of 0664 to feed to chmod() -- and apparently I can't just $r = 0.$r ; my way through it, because I get a parse error. Maybe I'm barking up entirely the wrong tree anyway. How can I set a file's permissions based on whatever umask() returns? TIA & HAND :-D -- David T-G davidtg@justpickone.org http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

« previous php.general (#183473) next »