On 15 April 2004 16:26, David T-G wrote:
> 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 ;
That would be
$r = '0'.$r;
I'm not sure, however, that this is a totally foolproof way of doing it, as
it would fail with any permission set (however unlikely) where the owner
odgit was a zero -- perhaps you should be sprintf()-ing it?
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php