RE: [PHP] file permissions or something like that...
| From: | Larry Hotchkiss | Date: | Fri, 05 Jan 2001 17:08:29 +0000 |
| Subject: | RE: [PHP] file permissions or something like that... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-32904@lists.php.net to get a copy of this message | ||
Its my understanding that 'fopen()' does nothing more than return a file
handle to access a file. Keeping that in mind, if you attempt to open a
file that does not exist, it will return false.
Also note, that files with an HTTP URL can only be opened for reading. If
you need to create a file and are on a unix system, perhaps use the exec()
to run 'touch' to create the empty file first.
Larry H.
On Friday, January 05, 2001 10:58 AM, Jason Jacobs
[SMTP:jason@factory7.com] wrote:
> Hello all. I have struggled with this problem for at least a week and no
> one seems to know how to fix it.
>
> Basically, I have a script that creates a directory when a new user signs
> on. The code is below:
> umask(011);
> mkdir("/path/to/dir/for/$newuser", 0777);
>
> Without the umask above the statement, the perms that were set were 755,
> even with the 777 explicitly stated (I know 777 is bad, but I'm going to
> make it 755 when it all works correctly), which confused me a lot, but as
> long as it works...
>
> So the directory is created fine with perms of 777. Then I want to
create
> some files, and update them as a database gets changed. The code for
> creating (and editing) the file is:
> if ($file = fopen ("path/to/dir/for/$newuser/index.htm", "w")){
> if (!(fwrite ($file, $htmldoc))){
> echo "unable to write to index file<br>";
> }//end if
> fclose($file);
> }//end if
>
> Each time this is run, I get the following error...
> fopen("path/to/dir/for/jason/Menu.htm","w+") - No such file or directory
>
> 1)Isn't fopen() supposed to create the file if it doesn't already exist,
and
> 2)if it's a permission error, why? The same user (http on our server)
that
> creates the directory is writing the file, so it should have the ability
to
> write the file, especially since the perms are 777 on the dir.
> 3)When I log into the site on my FTP program as the admin user for the
site,
> I can delete these folders that are created by PHP, but I can't open them
to
> see what's in them. That's confusing me too.
>
> BTW, I started using PHP a couple months ago, and all I did was jump in,
so
> I may be missing some pretty small things.
>
> Thanks for the help.
> Jason
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net