Re: PHP will not allow me to create new files that are unlocked?!



Subfolder permissions won't affect the permissions of newly created
files. For that, use umask:
http://us2.php.net/manual/en/function.umask.php

Run this and inspect the resulting permissions to get a feel for umask:

<?php

printf("My current umask is: %04o\n", umask());
umask(0077);
fopen("user_writable_only.txt", "w+");
umask(0007);
fopen("user_and_group_writable.txt", "w+");
umask(0000);
fopen("world_writable.txt", "w+");

?>

NB: In a real program, make sure you check the return values of fopen
and fwrite. Also, if you want to make sure a new file is being created
when you call fopen, use "x+" instead of "w+" for the second argument.
To change permissions on existing files, use chmod:
http://us2.php.net/manual/en/function.chmod.php

.



Relevant Pages

  • Re: File Sharing (again - sorry, Pd)
    ... InTerminal, type umask. ... Back in the good old days, Mac OS X user accounts ... The reason that the file permissions are "resetting" each time the ... that folder inherit the ACLs from the folder. ...
    (uk.comp.sys.mac)
  • Re: umask?
    ... setgid permissions used on your files and directories. ... the default umask value set on your system to 027, ... The shell does simple maths to determine what permissions are used on ... On a directory the maximum permissions will be drwxrwxrwx. ...
    (Fedora)
  • Re: [patch 12/13] ACL umask handling workaround in nfs client
    ... >> the umask locally, and sends the effective permissions to the server. ... >> only the default ACL determines the file's effective permissions. ...
    (Linux-Kernel)
  • Re: File Permissions problem : Cry for HELP
    ... is something wrnog with the server cause when i upload the same files from ... >> i have a problem with file permissions, each new file i need to create i ... >> Internal Server Error ... > You need to change the umask used when you are saving web files. ...
    (Fedora)
  • Re: default permissions when scping files
    ... >> username take on specific permissions, or barring that, ... I read it to mean that the umask does not affect the execute bit of files ... as the source file has. ...
    (comp.unix.shell)