Mercurial > hg > webaudioevaluationtool
comparison php/save.php @ 2224:760719986df3
Tidy up file locations.
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Thu, 14 Apr 2016 13:54:24 +0100 |
parents | |
children | ae69e61a6b76 |
comparison
equal
deleted
inserted
replaced
2222:4d1aa94202e3 | 2224:760719986df3 |
---|---|
1 <?php | |
2 error_reporting(0); | |
3 header('Access-Control-Allow-Origin: *'); | |
4 header("Content-type: text/xml"); | |
5 $postText = file_get_contents('php://input'); | |
6 $file_key = $_GET['key']; | |
7 $filename = "../saves/save-".$file_key.".xml"; | |
8 $fileHandle = fopen($filename, 'w'); | |
9 if ($fileHandle == FALSE) | |
10 { | |
11 // Filehandle failed | |
12 $xml = '<response state="error"><message>Could not open file</message></response>'; | |
13 echo $xml; | |
14 return; | |
15 } | |
16 $wbytes = fwrite($fileHandle, $postText); | |
17 if ($wbytes === FALSE) | |
18 { | |
19 // FileWrite failed | |
20 $xml = '<response state="error"><message>Could not write file "'.$filename.'"</message></response>'; | |
21 echo $xml; | |
22 return; | |
23 } | |
24 fclose($fileHandle); | |
25 | |
26 // Return XML confirmation data | |
27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"'.$filename.'"</file></response>'; | |
28 echo $xml; | |
29 ?> |