write to file? acces denied?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
opcd
Forum Newbie
Posts: 12
Joined: Mon Jun 03, 2002 12:54 pm

write to file? acces denied?

Post by opcd »

hey,

I got myself into trouble...
i wrote a guestbookscript which writes and reads from a textfile but it cant write to the text file; reading it doesn't seem to be a problem
when i try to write it gives following error:

"Warning: fopen("test.txt","w") - Permission denied "

i tried several things like filling in r+, a+, even "b" instead of "w" but it doesn't seem to work no matter what i try...

Code: Select all

<?php
$fileopenen = fopen($filepath, "a"); 
fwrite($fileopenen,$toevoegsel);
fclose($fileopenen);

?>
does this have to do with the server?
hope you guys can help me out...
greets opcd
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

most filesystems have permission settings for files. On unix-style systems that are (mainly) read, write and execute; permissions are set by the command chmod.
you may change the permissions either by php-script or ftp-client.
common settings are
chmod 755 <file>
or chmod 754 <file>
(depending on security matters - but a guestbook file.......)

take a look here:
a short tutorial on unix file permissions (there are plenty of those - this was the first returned by google ;) )
php chmod()
Post Reply