Hello, I'm sure I'm missing something really obvious but when I try to write to a file I get:

Failed to open stream: Permission denied

I have tryed changing the containing foders permissions to 770, 777, etc but nothing is working ;(, how might I fix this?

    I figure the more important than folder permissions are the file permissions so try to make them 777 and you should be able to succeed...

      bodzan wrote:

      I figure the more important than folder permissions are the file permissions so try to make them 777 and you should be able to succeed...

      Oh sorry I was rather vague. There is no file, I want the fopen() to also creating the file.

        From PHP manual for [man]fopen()[/man]:

        If PHP has decided that filename specifies a local file, then it will try to open a stream on that file. The file must be accessible to PHP, so you need to ensure that the file access permissions allow this access. If you have enabled safe mode, or open_basedir further restrictions may apply.

        You could consider trying to create a file with [man]touch()[/man] first and [man]chmod()[/man] it to 0777...

          No it denied that aswell ;(. Is there anything in the server's configuration that may be stopping it?

            To be sure of success:

            mkdir ('mydirectory');
            chmod('mydirectory',0777);
            touch('mydirectory/myfile');
            chmod('mydirectory/myfile',0777);

            If this doesn't work, then you have a server configuration problem.

              Nope, still denied 🙁.

              Do you know what problem in the configuration it might be? So I can tell my administrator.

                The directory where PHP is running is running with permissions set to restrict writing. The permissions for this directory must be reset to allow HHP to write.

                  Hmm, that didn't work either, but it doesn't matter, I'll do some other stuff, and come back to this problem when I know more... Thanks for your help.

                    The server admin will need to set the permissions -- you can't do it.

                      Write a Reply...