Search code examples
phpwindows-server-2012windows-serverphp-5.5

Windows Server: PHP Script unable to open and write file in Windows Server 2012


Is my first time working with Windows server 2012 and I am having a hard time trying to get a PHP script working. I have a PHP script that opens a JSON file, write the file and close it. Everything runs well but when I try to open a file in 'writing' mode an error is generated.

Here is the line where it fails:

 $myfile = fopen("master.json", "r+") or die("Unable to open file!");

When I open the files using "r" it opens without any issues, but when I try to open the file using "r+", "w", "w+", "a+", "x+" or "c+" is "unable to open file".

The PHP version on my server is 5.5.112.0.

Is there any permission issue I should be aware of? Something that I am missing? Any help will be appreciated.

Thank you!


Solution

  • The user running the webserver should need access to the file folder to be able to create the file. Can you create a file with global write permissions and then write to it?