I am running PHP 5.5.9 on Ubuntu 14.04. I am having trouble writing to a file. I feel this is a file permissions issue because I'm sure the code is correct. The user I signed up with has the rights to write to the folders I'm trying to write, but I'm not sure what localhost does. I am not sure what the localhost username is for using chmod . I tried using chmod 777 -R /var/www/html and the script still could not write to my target folder which has the path /var/www/html/Projects/MD_ScrapingTool/files . Here is my code:
$file = 'filetest.txt'; if($handle = fopen($file, 'w')) { $content = "123\n456"; fwrite($handle, $content); fclose($handle); } else { echo "Could not open file for writing."; }
php file-io ubuntu apache file-permissions
beznez
source share