Re: create file permission problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, June 13, 2007 12:13 pm, tedd wrote:
> I'm sure this is obvious to most, but not to me.
>
> I working on a virtual host.
>
> If I want to save data in a file, I can ftpconnect(); change the
> permissions of an existing file from 0755 to 0777; write to the file;
> and change the permissions of the file back to 0755 -- no problem.
>
> However, if a file is not there, then I can create one. However, the
> permissions of the file will be automagically set to 0600 and as
> such, I can't change them via ftpconnect(). In other words, I can't
> FTP in to my site and change the permissions of a file I created. I
> can delete the file, but that's all.
>
> How do you guys create a file and set its permissions working on a
> virtual host via php?

When your script creates the file, it creates it as itself, and not as
'you', which means that 'you' probably can't change it.

Fortunately, your php script owns the file, and it CAN change it.

In particular, before your script creates the file, it can use
http://php.net/umask to define what permissions the file should have,
or, after it's created, it can change the permissions with
http://php.net/chmod

> PS: If I remember correctly, it was pretty easy in perl. Just try to
> open/write a file and if it wasn't there, it created one for you.
> But, it's been years since I did any perl stuff -- could be wrong.

If Perl is running as 'you' then you'd have an easier time...

But if Perl was, say, mod_perl and running as the Apache user, you'd
be in the exact same boat as you are now.

PHP vs Perl is pretty irrelevant.

It's about who created the file with which permissions, and who's
trying to access it.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux