reply: ignore empty image uploads
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 15 Jan 2020 13:43:39 +0000 (14:43 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 4 Feb 2020 11:02:49 +0000 (12:02 +0100)
Fix invalid image appended for UPLOAD_ERR_NO_FILE.

widget/reply.php

index cedcc4919699194fe60926bf5a67adf316dfa38c..7e0ec1e83aea3c4c0819df20d9315f491db8ab8b 100644 (file)
@@ -10,14 +10,15 @@ if ($_POST) {
        require_once 'upload.inc.php';
        try {
                $html = messagehtml($_POST['reply']);
-               if ($_FILES and isset($_FILES['image'])) {
+               if ($_FILES and !empty($_FILES['image'])) {
                        $target = 'data/upload';
                        if (!file_exists($target)) {
                                throw new Exception("er is geen uploadmap aanwezig op $target");
                        }
                        $target .= '/' . $User->login;
-                       $result = userupload($_FILES['image'], $target);
-                       $html .= sprintf('<p><img src="/thumb/640x/%s" /></p>', $result);
+                       if ($result = userupload($_FILES['image'], $target)) {
+                               $html .= sprintf('<p><img src="/thumb/640x/%s" /></p>', $result);
+                       }
                }
                $query = $Db->set('comments', [
                        'page'    => $Page,