I Have a simple function that have to write on the file, it work on my local server but when i deploy it on the server it doesn’t write on the file? What is wrong ?
foo.php
<?
if (isset($_POST['data'])) {
$stringData = $_POST['data'];
$file = "ciao.txt";
$fh = fopen($file, 'w') or die("can't open file");
fwrite($fh, $stringData);
fclose($fh);
}
?>
function.js
function WriteToFile()
{
var data = "foo baaar";
$.post("JS/foo.php", {data: data}, function(result){ alert("label updated!!");}, "json");
}
fwrite() returns the number of bytes written, or FALSE on error.
change fwrite($fh, $stringData);
$written = fwrite($fh, $stringData);
print $written;
now you can get weather your data is getting written or not.
or you may set file permission using php code
chmod(“/somedir/somefile”, 0755);//750 or do testing with 777 ,then revert to 750 or what your admin suggest
/* try this one */