Mercurial > hg > webaudioevaluationtool
comparison save.php @ 1457:c8a9825aaa05
Merge from branch "WAC2016"
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Mon, 23 Nov 2015 09:13:12 +0000 |
parents | 04e8a9c07c7e |
children | cfe755cc2bc2 |
comparison
equal
deleted
inserted
replaced
1456:cacd98e7e1ff | 1457:c8a9825aaa05 |
---|---|
1 <?php | 1 <?php |
2 head('Access-Control-Allow-Origin: *'); | 2 header('Access-Control-Allow-Origin: *'); |
3 header("Content-type: text/xml"); | |
3 $postText = file_get_contents('php://input'); | 4 $postText = file_get_contents('php://input'); |
4 $datetime = date('ymdHis'); | 5 $datetime = date('ymdHis'); |
5 $xmlfile = "save".$datetime.".xml"; | 6 $xmlfile = "save".$datetime.".xml"; |
6 $fileHandle = fopen("saves/".$xmlfile, 'w'); | 7 $fileHandle = fopen("saves/".$xmlfile, 'w'); |
7 fwrite($fileHandle, $postText); | 8 if ($fileHandle == FALSE) |
9 { | |
10 // Filehandle failed | |
11 $xml = '<response state="error"><message>Could not open file</message></response>'; | |
12 echo $xml; | |
13 return; | |
14 } | |
15 $wbytes = fwrite($fileHandle, $postText); | |
16 if ($wbytes == FALSE) | |
17 { | |
18 // FileWrite failed | |
19 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>'; | |
20 echo $xml; | |
21 return; | |
22 } | |
8 fclose($fileHandle); | 23 fclose($fileHandle); |
24 | |
25 // Return JSON confirmation data | |
26 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>'; | |
27 echo $xml; | |
9 ?> | 28 ?> |