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'])) {
--- /dev/null
+<?php
+function userupload($input, $target)
+{
+ switch ($input['error']) {
+ case UPLOAD_ERR_OK:
+ break;
+ case UPLOAD_ERR_NO_FILE:
+ return; # current
+ default:
+ throw new Exception("Afbeelding niet goed ontvangen.");
+ }
+ if (!@move_uploaded_file($input['tmp_name'], $target)) {
+ throw new Exception("Fout bij opslaan.");
+ }
+
+ foreach (@glob('thumb/*/') as $thumbres) {
+ # attempt to remove old derivations
+ @unlink($thumbres . '/' . $target);
+ }
+ return $target;
+}