From 5c74f1d42567cf08df3566104ab0b7d7c26e35c6 Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Wed, 25 Dec 2019 23:49:47 -0700 Subject: [PATCH] Use SplFileInfo::isFile() method for checking if path is a file --- app/Controllers/FileInfoController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Controllers/FileInfoController.php b/app/Controllers/FileInfoController.php index 38c3a9f..b64566d 100644 --- a/app/Controllers/FileInfoController.php +++ b/app/Controllers/FileInfoController.php @@ -29,11 +29,12 @@ class FileInfoController */ public function __invoke(Response $response, string $path = '.') { - if (! is_file($path)) { + $file = new SplFileInfo($path); + + if (! $file->isFile()) { return $response->withStatus(404, 'File not found'); } - $file = new SplFileInfo($path); if ($file->getSize() >= $this->config->get('app.max_hash_size', 1000000000)) { return $response->withStatus(500, 'File size too large'); }