Reputation: 31
I'm using Ubuntu 16.04 and I'm trying the following code to write to a file.
<?php
$path = getcwd();
$fp = fopen($path . 'data.txt', 'w') or die("Can not open the file");
fwrite($fp, '1');
fwrite($fp, '23');
fclose($fp);
Initially the file permissions on data.txt was -rw-r--r-- and causing the following error:
fopen(data.txt): failed to open stream: Permission denied
So I changed file permissions to -rw-rw-rw-, but nothing is happening now. It is neither writing to a file nor showing any error.
Can anybody please help me what has went wrong here?
Thanks in advance.
Upvotes: 2
Views: 1294