I get error messages everytime something tries to create or write to a file saying permission denied:

Warning: fopen(counter/061eb69b1f51d2b0dc1d16268d764558.txt): failed to open stream: Permission denied in /home/aaron/site/item.php on line 136

Warning: fwrite(): supplied argument is not a valid stream resource in /home/aaron/site/item.php on line 137

Warning: fclose(): supplied argument is not a valid stream resource in /home/aaron/site/item.php on line 138

The rest of the page shows up correctly. Those files have the same permissions as every other file in the directory.

    the folder has to have public permissions as well, not just the file.

      u might want to use chmod() function before fopen() and after fclose()

      something like
      chmod("filename",707);
      $handle=fopen("filen...
      ...
      ..
      fclose($handle);
      chmod("filename",704);

      Hope this helps

      TommYNandA

        the thing is, this works on my webserver, but not on my localserver. Everything else works. I can create users, modify config files through the admin pages, this part of the code just comes back with errors on the localhost only.

          Wats is your local server on?
          OS
          WebServer -- IIS? or Apache?

            Both are Apache, how could I find out what user is running apache? Because I think that whoever is, doesn't have write permissions on the folder that the site is in.

              Sorry I misread the post directly above this one. If its *nix you can run ps -faux and then the user should be on the left of the ouput which corresponds to apache.

              OLD POST
              Are you sure the webserver has permission to the files and directories? It could be that the permission is for yourself and apache runs as the nobody or www-data user.

                OS- Windows? Linux?

                how could I find out what user is running apache?

                what does that mean??

                  Originally posted by tommynanda

                  how could I find out what user is running apache?

                  OS- Windows? Linux?



                  what does that mean??

                  I think what he means (keep in mind I am not sure how familiar you are with unix) is that on unix users run things. root starts most processes but certain users take control after that.

                  He needs to know what user the webserver runs as so that he can make sure the files which are going to wrote to have permissions allowing that user and only that user to write to them.

                    yep, that's what it is, nobody is running apache. But my site is in my home directory. I've searched chmod tutorials but can't figure out how I can just add nobody or the group nobody to my home directory?

                      I would not advise that. If its your server make a new place for your site and then give it permission. If its a webhosting company's server, create a dir in your home dir and ask them kindly to give nobody permission to it. ONLY root can do this.

                        well, I could put it in the htdocs directory that apache defaults to, but then I'd be in the same position trying to give me permissions to write to that directory wouldn't I?

                          Write a Reply...