PDA

View Full Version : Setting write permissions



Objectivity
12-04-2007, 06:06 PM
I've just switched to a new server (GoDaddy) and I now have an issue with files that are created through the website. Users will go into a form and that data will be saved into a csv file. The server saves the file as rw-r--r--.

I've tried adding this line (with and without the quotes) in my php script when the file is processed. It doesn't seem to do anything.

chmod("$changeFile", 0666);

The files that are created are giving the group/username of apache. The rest of the files have a different default name.

Basically, I need a way to automatically set the write permissions of the files when they're created so they can later be edited/deleted.

I've searched for scripts to do this, but none seem to be effective. The fault is probably mine more than the scripts, this just isn't an area where I have a lot of background.

thetestingsite
12-04-2007, 07:48 PM
Is the server a Windows or Linux server? If the first, I have noticed that you will not really be able to change the permissions of any files/folders on the server; however, you are still able to write to them if they are the same usergroup as the script being ran. If the latter, you should be able to do what you have posted above (the chmod part) if the script and the file are owned by the same user/group.

Hope this helps.

Objectivity
12-05-2007, 01:55 PM
Is the server a Windows or Linux server? If the first, I have noticed that you will not really be able to change the permissions of any files/folders on the server; however, you are still able to write to them if they are the same usergroup as the script being ran. If the latter, you should be able to do what you have posted above (the chmod part) if the script and the file are owned by the same user/group.

Hope this helps.

It does. But it raises another question. How do I change who the file is owned by. The script is owned by "girlscouts." The file being created is owned by "apache." The easiest solution would be to change the owner of the new file, but I can't see an easy way to do that. Is there a command to change owners when you're not that owner?

thetestingsite
12-05-2007, 02:55 PM
You could use chown (http://php.net/chown) to change the owner (I believe it would work)

Hope this helps.