I have this simple code:
<?php
$myFile ='test.txt';
$myContent ='Some text';
file_put_contents($myFile, utf8_encode($myContent));
?>
the location of the test.txt file is here:
/srv/www/htdocs/didebansnort
the page that I wrote this php code in browser:
http://localhost/dideban开发者_如何学Gosnort/testdl.php
the code is not working it will not write the string on it
RESULT:in properties it wasn't sufficient to set the permissions
Make sure that the user PHP/Apache runs as has write permissions to that file.
In Linux, you can give read (r), write (w) and execute (x) rights either to yourself, your group(s) or everyone else. Make sure you either give write permissions to a group that has both you and the PHP user as members, or give write access to everyone (not to be used in production).
You're stating you use OpenSuse, you can find more details about permissions here:
- 7.3 File Access Permissions
- 8.5 Modifying File Permissions
This this:
$myFile ='./test.txt';
精彩评论