I am trying to save a json string from a javascript file to a local file on the server using PHP, however, my json file is not being modified at all. Here is my Javascript:
function saveToFile(data){
jsonString = JSON.stringify(data);
$.ajax({
url: 'php/save.php',
data : jsonString,
type: 'POST'
});
}
Note that jsonString is a valid variable, and i can log it correctly into the console.
Here is my PHP:
<?php
$data = $_POST['jsonString'];
$f = fopen("../website-contents.json", "w") or die("fopen failed");
fwrite($f, $data) or die("fwrite failed");
fclose($f);
?>
Note that even tests trying to save "Hello World" to "test.txt" don't work, or through errors.
Finally, here is my folder structure:

file_put_contents( $uploadLocation."/filename.json", $fileJsonString );Make sure you have the correct write permissions on where you are going to save this.<?phptagerror_reporting(E_ALL); ini_set('display_errors', 1);