fopen() fails to open stream: permission denied, yet permissions should be valid

前端 未结 2 854
小鲜肉
小鲜肉 2021-01-18 03:15

So, I have this error:

Warning: fopen(/path/to/test-in.txt) [function.fopen]: failed to open stream: Permission denied

Performing ls

2条回答
  •  心在旅途
    2021-01-18 04:01

    Another reason of this error may be that the directory of file does not exist.

    I just add php code before fopen:

    if(!file_exists(dirname($file))) 
        mkdir(dirname($file));
    

    This help me out.

提交回复
热议问题