Re: file permissions for uploaded files

From: Date: Sat, 03 May 2003 16:53:32 +0000
Subject: Re: file permissions for uploaded files
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-146287@lists.php.net to get a copy of this message
On Friday 02 May 2003 19:53, Elmer van Geijn wrote: > Below is part of a 'ls -l' on the upload directory. I cannot detect > any consistency between the type of the file being uploaded and the > permissions set on the uploaded file. (the real filenames belonging > to the files are stored in a MySQL database) > > -rwxr-xr-x 1 www www 32768 Jan 29 12:46 17245 > -rwxr-xr-x 1 www www 13824 Jan 29 12:46 17246 > -rw------- 1 www www 49152 Jan 29 17:11 17291 > -rw------- 1 www www 38400 Jan 29 17:35 17294 > -rwxr-xr-x 1 www www 292864 Jan 29 17:53 17305 [snip] > >> Can anyone tell me how php decides what permissions > >> to set on uploaded files, and whether I can force them? I'm > >> using both copy() and move_uploaded_file() for handling files > >> on the server. > > > > You could try using umask(). > > That would probably work, but still leaves we puzzled about > how php comes up with these permissions. I've done some tests and this is what I've found: 1) I have not seen any 'random' arbitary assigning of perms to uploaded whether using move_uploaded_file() or copy(). 2) If I use move_uploaded_file() then perms will be: -rw------- 1 apache apache 54709 May 4 00:46 3eb3f24e9ea15 regardless of umask. 3) If I use copy() then umask will be taken into consideration. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* The purpose of Physics 7A is to make the engineers realize that they're not perfect, and to make the rest of the people realize that they're not engineers. */

« previous php.general (#146287) next »