From: Mischa POSLAWSKY Date: Wed, 11 Jul 2018 19:09:21 +0000 (+0200) Subject: login/edit: move upload handling code into include X-Git-Tag: v3.5~6 X-Git-Url: http://git.shiar.net/minimedit.git/commitdiff_plain/ab3ebc53acde6f060649a01403a886f5485f7bf6 login/edit: move upload handling code into include --- diff --git a/login/edit.php b/login/edit.php index 15b0a2a..101244a 100644 --- a/login/edit.php +++ b/login/edit.php @@ -123,27 +123,19 @@ if ($_POST) { if (!isset($cols[$col]) and @$cols[$col]['type'] == 'file') { continue; # unknown } - switch ($val['error']) { - case UPLOAD_ERR_OK: - break; - case UPLOAD_ERR_NO_FILE: - continue 2; # current - default: - $colwarn[$col] = "Afbeelding niet goed ontvangen."; - continue 2; - } if (empty($cols[$col]['target'])) { $colwarn[$col] = "Kan niet worden aangepast."; continue; } - if (!@move_uploaded_file($val['tmp_name'], $cols[$col]['target'])) { - $colwarn[$col] = "Fout bij opslaan."; + try { + require_once('upload.inc.php'); + $target = userupload($val, $cols[$col]['target']); + if (!$target) continue; + $cols[$col]['value'] = ''; } - foreach (@glob('thumb/*/') as $thumbres) { - # attempt to remove old derivations - @unlink($thumbres.'/'.$cols[$col]['target']); + catch (Exception $e) { + $colwarn[$col] = $e->getMessage(); } - $cols[$col]['value'] = ''; } if (!empty($_POST['newpass'])) { diff --git a/upload.inc.php b/upload.inc.php new file mode 100644 index 0000000..aa24558 --- /dev/null +++ b/upload.inc.php @@ -0,0 +1,21 @@ +