I'm trying to create a file through fopen() as below :

<?php 
  $handle = fopen('name.txt', 'w') or die('Can\'t create file');
  fwrite($handle, 'Hamed'."\n");
  fwrite($handle, 'Kamrava'."\n");
  echo 'File was created successfully';
?>

But doesn't create that file and get me:

Can't create file

P.S :

I'm using LAMP server on Linux/Ubuntu.

I've tried below command before creating that file:

sudo chmod -R 755 ~/public_html/

Any ideas would be appreciated.

Edit
Report