I often come across negative comments whenever I want a PHP script to write output to a file on the server.
I use functions fopen(), fwrite()and fclose().
fopen()
fwrite()
fclose()
The only way I know how to do this is to either set the permissions for the output file to 0666, or use its "nobody" (which is the user that PHP runs on our Apache web server).
So, if “0666” or “belongs to no one” is a security risk, how do you successfully and safely allow a PHP script to write to a file?
Thank you for the joint guidance on this topic.
PHP , , - (apache ) . , , , script . , , . :
getfile.php?file=1.txt
2.txt
/etc/passwd
PHP, . chmod chown, apache. , cron script ( ) PHP. , , , , .
chmod
chown
, , . , , , , ... . .
, , . .