upload and file permissions

Hello group,

I'm implementing file upload in webpage. And got stuck with file
permissions. An uploaded file gets 0600 and as such cannot be shown in
the webpage, as far as I understand it needs at least 0644.

So I did a little investigation and found:
1) the upload folder has 0755, set by hand.
2) echo `umask` in the upload folder and actually in the higher levels
of the webserver folders gives 0022.
3) a file created by fopen in php file called via webserver gets 0644,
in the upload folder.
4) and, as already said, uploaded file gets 0600.

Where did that 0022 (Group,Other: Write) appear from? Is it right for
the webserver?
How to upload file with 0644 permissions?


Andra.
kkadrese [ Fr, 16 Februar 2007 10:16 ] [ ID #1631492 ]

Re: upload and file permissions

kkadrese [at] yahoo.com wrote:
> Hello group,
>
> I'm implementing file upload in webpage. And got stuck with file
> permissions. An uploaded file gets 0600 and as such cannot be shown in
> the webpage, as far as I understand it needs at least 0644.
>
> So I did a little investigation and found:
> 1) the upload folder has 0755, set by hand.
> 2) echo `umask` in the upload folder and actually in the higher levels
> of the webserver folders gives 0022.

Why use "echo"? you get the value by just using umask without arguments.

> 3) a file created by fopen in php file called via webserver gets 0644,
> in the upload folder.
> 4) and, as already said, uploaded file gets 0600.

from the php.ini:

; The file storage module creates files using mode 600 by default.
; You can change that by using


> Where did that 0022 (Group,Other: Write) appear from? Is it right for
> the webserver?

The server/php don't regard the umask that the standard shell has.
I do guess the easiest is to change the privilege bits from within php with
chmod() or set another umask with umask().

http://www.php.net/manual/en/function.chmod.php
http://www.php.net/manual/en/function.umask.php


--

//Aho
Shion [ Fr, 16 Februar 2007 10:26 ] [ ID #1631493 ]

Re: upload and file permissions

> > Hello group,
> >
> > I'm implementing file upload in webpage. And got stuck with file
> > permissions. An uploaded file gets 0600 and as such cannot be shown in
> > the webpage, as far as I understand it needs at least 0644.
> >
> > So I did a little investigation and found:
> > 1) the upload folder has 0755, set by hand.
> > 2) echo `umask` in the upload folder and actually in the higher levels
> > of the webserver folders gives 0022.
>
> Why use "echo"? you get the value by just using umask without arguments.

I tested it form my internet browser.


> > 3) a file created by fopen in php file called via webserver gets 0644,
> > in the upload folder.
> > 4) and, as already said, uploaded file gets 0600.
>
> from the php.ini:
>
> ; The file storage module creates files using mode 600 by default.
> ; You can change that by using

Nothing of the kind in my php.ini.


> > Where did that 0022 (Group,Other: Write) appear from? Is it right for
> > the webserver?
>
> The server/php don't regard the umask that the standard shell has.
> I do guess the easiest is to change the privilege bits from within php with
> chmod() or set another umask with umask().
>
> http://www.php.net/manual/en/function.chmod.php
> http://www.php.net/manual/en/function.umask.php

ok, it seems I should use chmod for each uploaded file. Currently it
works.
Thank you!

>
>
> --
>
> //Aho
kkadrese [ Fr, 16 Februar 2007 12:13 ] [ ID #1631500 ]
PHP » alt.php » upload and file permissions

Vorheriges Thema: can any1 recommend script
Nächstes Thema: lasdl;