To effectively store received data, a server is essential.
Utilizing resources like the mentioned tutorial can guide you through this process.
The key adjustment required is for the PHP server to write the content from the post request onto disk. A snippet such as the one below should suffice:
Keep in mind that testing and potential modifications may be necessary.
<?php
// Handling CORS
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400');
}
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
exit(0);
}
$postdata = file_get_contents("php://input");
if (isset($postdata)) {
$request = json_decode($postdata);
$myfile = fopen("newfile.json", "w") or die("Unable to open file!");
fwrite($myfile, $request);
fclose($myfile);
}
else {
echo "Incorrect call!";
}
?>