1. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Hello, Iīm trying to open a file on the server using the following (which works fine on my machine):
    v$fd = fopen("/path_to_folder/x-files.txt", "r+");
    while ($text = fgets($fd, 4096)) {
    echo $text;
    I can only open it to read (using r), if I try to write to it as well ( r+ ) I get a "Permission Denied" error message. Strange thing: my serveradmin tells me that I have all the necessary rights so that writing shouldnīt fail. What is wrong? What kind of rights exactly do I need (chmod to :...)??
  2. #2
  3. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    It's not necessarily a matter of what YOU have rights to - it's a matter of what the WEB SERVER has rights to (assuming PHP compiled into Apache).

    You're going to have to find out what user/group the web server runs as and then set your file permissions accordingly.

    Easiest would be to set the file's owner to yourself and set the file's group to the webserver's group.

    Then chmod 664 (rw-rw-r--) or 660 (rw-rw----) to give the webserver's group write permissions.

    Or check to make sure that PHP isn't running in safe mode (in which case it won't deal with files outside its directory).

IMN logo majestic logo threadwatch logo seochat tools logo