-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendData.php
More file actions
27 lines (20 loc) · 720 Bytes
/
sendData.php
File metadata and controls
27 lines (20 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
// location of the folder to write to on the server,
// relative to the php file.
$base = '../../../private/videoGameExperiments/';
$jsonData = file_get_contents('php://input');
// Convert it to json, then convert it back to a pretty-printed string
// (may want to remove if causing problems)
$jsonData = json_decode($jsonData);
$jsonData = json_encode($jsonData, JSON_PRETTY_PRINT);
// create a temporary file name
$data_filename = tempnam($base,'EXP');
rename($data_filename, $data_filename .= '.json');
//var_dump($data_filename);
//set to writeable, but this may not be necessary
chmod($data_filename, 0644);
// Write to filename
$fp = fopen($data_filename, 'w');
fwrite($fp, $jsonData);
fclose($fp);
?>