Mercurial > hg > webaudioevaluationtool
diff php/save.php @ 2997:a10cbbccc4f3
#193. Partial files save with prefix ‘update’. Partials are deleted once full test is submitted and saved.
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Wed, 02 Aug 2017 08:50:19 +0100 |
parents | 19ec114ea8c6 |
children | 12b90c6ff910 |
line wrap: on
line diff
--- a/php/save.php Wed Aug 02 08:29:23 2017 +0100 +++ b/php/save.php Wed Aug 02 08:50:19 2017 +0100 @@ -33,7 +33,17 @@ } $postText = file_get_contents('php://input'); $file_key = $_GET['key']; -$filename = '../saves/'.$saveFilenamePrefix.$file_key.".xml"; + +$update = false; +if (isset($_GET["update"])) { + $update = $_GET["update"] == "update"; +} + +if ($update) { + $filename = '../saves/update-'.$saveFilenamePrefix.$file_key.".xml"; +} else { + $filename = '../saves/'.$saveFilenamePrefix.$file_key.".xml"; +} if (!file_exists($filename)) { die('<response state="error"><message>Could not find save</message></response>'); @@ -132,4 +142,8 @@ // Return XML confirmation data $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"'.$filename.'"</file></response>'; echo $xml; + +if (!$update) { + unlink('../saves/update-'.$saveFilenamePrefix.$file_key.".xml"); +} ?>