added new stuff for asset management

This commit is contained in:
Luca Haid
2025-06-27 10:48:32 +02:00
parent 62956e1539
commit fe73aa22ab
8 changed files with 690 additions and 210 deletions

View File

@@ -88,4 +88,25 @@ class FileController extends mfBaseController {
]);
}
protected function showAction() {
$id = $this->request->id;
if (!is_numeric($id) || $id < 1) return true;
$file = new File($id);
if (!$file || !$file->id) throw new Exception("File record not found", 404);
$path = MFUPLOAD_FILE_SAVE_PATH . ($file->subfolder ? "/{$file->subfolder}" : "") . "/{$file->store_filename}";
if (!is_readable($path)) throw new Exception("Physical file not found", 4041);
if (($imageInfo = @getimagesize($path)) !== false) {
header('Content-Type: ' . $imageInfo['mime']);
header('Content-Disposition: inline; filename="' . ($file->orig_filename ?: $file->store_filename) . '"');
readfile($path);
exit;
} else {
throw new Exception("File is not a displayable image.", 415);
}
}
}