forked from catmanjan/anutimetable
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsave.php
39 lines (35 loc) · 835 Bytes
/
save.php
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
28
29
30
31
32
33
34
35
36
37
38
39
<?php
try
{
$data = $_POST['jsonString'];
$term = $_GET['term'];
if (!empty($data) && !empty($term))
{
$term = $_GET['term'];
$file = '/data/configTableFall.json';
if ($term == "Winter")
$file = '/data/configTableWinter.json';
//set mode of file to writable.
chmod(dirname(__FILE__). $file,0777);
$f = fopen(dirname(__FILE__). $file, "w+") or die("fopen failed");
fwrite($f, $data);
fclose($f);
echo json_encode(array(
'status' => 'success',
'message'=> 'success message'
));
}
else{
echo json_encode(array(
'status' => 'error',
'message'=> 'error data empty'
));
}
}
catch ( Exception $e ) {
// send error message if you can
echo json_encode(array(
'status' => 'error',
'message'=> 'error message'
));
}