edit: store file uploads to data/$year/
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 29 Sep 2017 12:08:26 +0000 (14:08 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Fri, 29 Sep 2017 13:56:31 +0000 (15:56 +0200)
edit.php

index 1b81ccf2aa8f4242dbcdddeaecd7d7636c5e17f7..75b80b3b86432a4dd02e076bacb708c84a56cea5 100644 (file)
--- a/edit.php
+++ b/edit.php
@@ -10,6 +10,17 @@ function abort($body, $status = NULL) {
 if (!@$User['admin'])
        abort("geen beheersrechten", '401 unauthorised');
 
+if ($_FILES) {
+       $img = @$_FILES['upload'];
+       if (!$img or $img['error'] !== UPLOAD_ERR_OK)
+               abort('bestand niet goed ontvangen: '.$img['error'], '409 upload error');
+
+       $datadir = 'data/' . date('Y');
+       $target = $datadir.'/'.$img['name'];
+       move_uploaded_file($img['tmp_name'], $target);
+       abort($target);
+}
+
 if (!$_POST)
        abort("niets te doen", '405 post error');
 if (!$Args)