Use SplFileInfo::isFile() method for checking if path is a file

This commit is contained in:
Chris Kankiewicz
2019-12-25 23:49:47 -07:00
parent c82f3d6cde
commit 5c74f1d425

View File

@@ -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');
}