diff --git a/lib/filepicker.php b/lib/filepicker.php index 5377058..7bcbaff 100644 --- a/lib/filepicker.php +++ b/lib/filepicker.php @@ -16,6 +16,13 @@ if (isset($VARS['path']) && file_exists($base . $VARS['path']) && strpos(realpat $folder = $VARS['path']; } +// Compared to the start of the file mimetype, if it doesn't match the file is +// skipped. A type of "image" will match "image/png", "image/jpeg", etc. +$type = []; +if (isset($VARS['type']) && $VARS['type'] != "") { + $type = explode("|", $VARS['type']); +} + if ($folder == "/") { $folder = ""; } @@ -75,6 +82,21 @@ $fullpath = $base . $folder; if (array_key_exists($extension, $EXT2MIME)) { $mimetype = $EXT2MIME[$extension]; } + + $found = true; + if (count($type) > 0) { + $found = false; + foreach ($type as $t) { + if (strpos($mimetype, $t) === 0) { + $found = true; + break; + } + } + } + if (!$found) { + continue; + } + // Lookup icon from mimetype if (array_key_exists($mimetype, $MIMEICONS)) { $icon = $MIMEICONS[$mimetype]; @@ -103,7 +125,7 @@ $fullpath = $base . $folder;

- +