FoggyLog

Sat Sep 19th 2015 11:57:12: Synology NAS - PHP Function fopen() fails on Webserver

Out of the box, when you try and open a file for writing using fopen the function fails with a permissions error such as "Warning: fopen(file.txt): failed to open stream: Permission denied in /volume1/web/index.php"

To resolve this...

  1. Open the Synology Diskstation Control Panel
  2. Click on "Shared Folder"
  3. Click on the shared folder that contains the file your PHP is trying to open for writing.
  4. Click "Edit"
  5. Go to permissions
  6. Choose "Local Groups"
  7. Give the group "http" Read/Write access
  8. Click OK

It then should work

 

Thanks! Worked like a charm.

Comment by T. Hutchin at 0:00 on Thu 4 May 2017

It worksª

Thx

Comment by Beamen at 16:29 on Mon 16 April 2018

I've been searching for hours to find out why I couldn't create files with PHP on my NAS and this is the only place that had the answer.

Thank you.

Comment by Mat at 21:52 on Sun 10 November 2019

Thanks a lot! I've also searched for hours, and try to chown files on my NAS to get this to work. Finally!

Comment by Cornelis at 21:02 on Sun 19 January 2020

Brilliant, I had been searching all over for a solution to this, I still don't really understand that when the file (and directories) are set to 777 I still can't access the file. There must be another layer of security above or below Linux's standard !! who know - but this works !! Thanks so much..

Comment by Rich S at 18:03 on Fri 13 November 2020

OMG ....... i wasted hours on this ..... until I saw this I was pulling my hair out THANK YOU !!!

I debugged and debugged and saw the user was "http" but I could not find a user named that on the Synology box

Comment by Joe at 4:16 on Mon 8 March 2021

Fantastic - this worked perfectly even today. (Tue, 09-03-2021).

You'd think there'd be a more obvious way..?

Comment by bill at 12:35 on Tue 9 March 2021

Thank you! This saved me hours!

Comment by Terry at 21:29 on Thu 23 December 2021

Add New Comment

Name:
Email:
(Never displayed publically)
Comment:
HTML Tags allowed - <b>bold</b>, <i>italic</i> and <a href="http://...">Links</a>
Type "NoSpam" in Here:

 

<< Back