php file_put_contents can't create files on apache server directory
<p>I have installed apache server on a linux fedora machine
and I put the following test.php and test.html on var/www/html
but when I open the 127.0.0.1/test.html on firefox
the test.php doesn't create the text.txt file, let alone write the string to the file
and the there is also no output for "echo $var" </p>

<p>the error is </p>

<pre><code>Warning: file_put_contents(test.txt): failed to open stream: Permission denied in /var/www/html/getdata.php on line 7
</code></pre>

<p>the permission for the directory is:</p>

<pre><code>drwxr-xr-x. 2 root root 4096 Nov  6 14:14 html
</code></pre>

<p>test.php:</p>

<pre><code>&lt;?php
$v="x";
$fname='test.txt';
$rv=file_put_contents($fname,$v);
echo $rv;
echo $v;
?&gt;
</code></pre>

<p>the test.html is so complex coz I planned to write something complex to a file on the server, but since there is some problem, I simplified the test.php</p>

<p>test.html:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;

&lt;form id="yourFormID" method="POST" action="/getdata.php" &gt;&lt;/form&gt;

&lt;script&gt;
  function sendArray( theArray )
  {
    var frm = document.getElementById('yourFormID');
    fld = document.createElement("INPUT");
    fld.name ="data"; 
    fld.type = "hidden";
    fld.value = JSON.stringify(theArray);
    frm.appendChild(fld);  
    frm.submit();
   }

   var yourArray = [0.000023323,0.00001292,0.00003323];

    sendArray( yourArray );

    &lt;/script&gt;
    &lt;/body&gt;
    &lt;/html&gt;
</code></pre>
