Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

php - fopen Permission denied on a file with 777 permissions

Since the title of this post is pretty much self-explanatory, I'll just jump to the code :

echo sprintf('%o', fileperms('test.txt'))."<br/>";

fopen("test.txt", "w");

And with this I get :

100777
fopen(test.txt): failed to open stream: Permission denied

Any ideas ?

Edit : Problem solved : there were access control lists on the server that were not configured correctly.

Thanks !

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think its possible that you have write/read permissions on the file but not on the folder. Try this in the public root of your website and see if you can read or write the file.

For safe mode (http://php.net/manual/en/function.fopen.php), php doc's say the following:

Note: When safe mode is enabled, PHP checks whether the directory in which the script is operating has the same UID (owner) as the script that is being executed.

Last you also need to be sure that php has access to the folder you are trying to write to.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...