Re: PHP will not allow me to create new files that are unlocked?!
- From: "Mike Gatny" <gatny@xxxxxxxxxxxxxxxxxxxxx>
- Date: 14 Sep 2005 20:53:46 -0700
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
.
- References:
- PHP will not allow me to create new files that are unlocked?!
- From: monomaniac
- PHP will not allow me to create new files that are unlocked?!
- Prev by Date: Re: Populate picklist from directory and return file name
- Next by Date: PHP + JAVA Extension problem
- Previous by thread: PHP will not allow me to create new files that are unlocked?!
- Next by thread: preg_match_all and css
- Index(es):
Relevant Pages
|