From 85d01336fad3b3110a6bdb395593e29260714acc Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 5 Jan 2020 22:21:25 +0100 Subject: [PATCH] reply: accept image uploads with messages --- widget/reply.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/widget/reply.php b/widget/reply.php index 9e1c7e3..cedcc49 100644 --- a/widget/reply.php +++ b/widget/reply.php @@ -9,9 +9,19 @@ $journalcol = [ if ($_POST) { require_once 'upload.inc.php'; try { + $html = messagehtml($_POST['reply']); + if ($_FILES and isset($_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('

', $result); + } $query = $Db->set('comments', [ 'page' => $Page, - 'message' => messagehtml($_POST['reply']), + 'message' => $html, 'author' => $User->login, ]); if (!$query->rowCount()) { @@ -94,7 +104,7 @@ while ($row = $query->fetch()) { if ($User) { print '
  • '; - print '
    '; + print ''; if (isset($Issue) and $User->admin("edit $Page")) { print '

    '; printf( @@ -115,6 +125,13 @@ if ($User) { ); print "

    \n"; } + if (isset($Issue)) { + printf( + '

    ' + . '

    '."\n", + 'image', 'Beeldmateriaal', ' type="file" accept="image/*"' + ); + } printf(''."\n", 'reply', "Bericht van {$User->login}", -- 2.30.0