rtimmons wrote in php

PHP, Permissions, and You

Hey all,

I have a script that generates files using the fopen($file,'w+') function to create files that may or may not already exist, and it seems to be working fine but with one small gotcha--the permissions are for whatever reason set to 644 (decimal). This isn't a huge problem except that it doesn't give me enough permissions to edit the file using ftp or ssh (i.e. I can still get at it with another php script, but I can't modify it directly).

I've tried using the chmod($file,077) command, but it's obviously disabled as it has no effect. I do not have access to the php.ini file, although I do have ssh access to my directory on the machine. (I do not have a sudo password.) I tried using the chmod command in unix, but of course I don't have high-enough permissions.

I've googled a fair amount and haven't come up with too much other than the already-mentioned and failed chmod commands and functions.

Anybody know how to get php to create a new file with more liberal permissions?