Ubuntu14 server file path: /home/megadmin/public_html/mytestsite.com/index.php
<?php chdir(dirname(__FILE__)); file_put_contents("working.txt","hello world"); ?> the problem is that if you run the file from the server console with megaadmin rights, the working.txt file is saved in the current folder: /home/megadmin/public_html/mytestsite.com , and if you open the file through a browser, it displays in the error logs:
PHP Warning: file_put_contents(working.txt): failed to open stream: Permission denied in /home/megadmin/public_html/mytestsite.com/index.php on line 5
What could be a mistake?