Jump to content

Question on how to change owner/group of file when it is written


Nimrodtsst

Recommended Posts

I've found plenty of information on changing file permissions for existing files, but what I want to do is the following:

I've written a simple application to read an XML document, append to it, and then write the result back out...

The only problem is that when the file gets written, its owner is "nobody" and group is "no group", so it doesn't have permission to write in the environment I'm in. 

I'm not very experienced with PHP at all, so I don't know where to change these, but the system admin here would be willing to change any PHP preferences/configurations if that's needed.

Thanks in advance for any help.  I'm sorry if there have been posts like this before, but I haven't been able to find any on this board or across the net.
The best way would be having PHP to run as CGI.  When PHP run as CGI, it have full permision to any files on your server.  This way, you can read or write whatever file you wanted.

Unfortunately, PHP commonly installed as Module on most hosting service provider and therefore, it run with permission of user.

Contact your hosting service regarding how to set permission of your PHP user.  Some host allow you to change this permission. 

The last solution would be using FTP connection.

//connect to ftp, set the file permission to 0777, (world writable)
// write/append to the file
//connect to ftp, set the file permission to 0755, (world read and execute)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.