added new stuff for asset management
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user