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"
the error is
Warning: file_put_contents(test.txt): failed to open stream: Permission denied in /var/www/html/getdata.php on line 7
the permission for the directory is:
drwxr-xr-x. 2 root root 4096 Nov 6 14:14 html
test.php:
<?php
$v="x";
$fname='test.txt';
$rv=file_put_contents($fname,$v);
echo $rv;
echo $v;
?>
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
test.html:
<!DOCTYPE html>
<html>
<body>
<form id="yourFormID" method="POST" action="/getdata.php" ></form>
<script>
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 );
</script>
</body>
</html>