From 8a3c0639adf84f028685009ec4f848cfd07374c0 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 26 Sep 2025 10:26:04 +0530 Subject: [PATCH] Refactor readFiles method to improve .txt file filtering logic --- app/Http/Controllers/SapFileController.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/SapFileController.php b/app/Http/Controllers/SapFileController.php index 7a770ed52..a95f2800e 100644 --- a/app/Http/Controllers/SapFileController.php +++ b/app/Http/Controllers/SapFileController.php @@ -58,9 +58,14 @@ class SapFileController extends Controller } // Filter only .txt files - $files = array_filter($allFiles, function($file) use ($path) { - return $file !== '.' && $file !== '..' && is_file($path . $file) - && pathinfo($file, PATHINFO_EXTENSION) === 'txt'; + // $files = array_filter($allFiles, function($file) use ($path) { + // return $file !== '.' && $file !== '..' && is_file($path . $file) + // && pathinfo($file, PATHINFO_EXTENSION) === 'txt'; + // }); + + $files = array_filter($allFiles, function($item) use ($path) { + $fullPath = $path . '/' . $item; + return @is_file($fullPath) && pathinfo($item, PATHINFO_EXTENSION) === 'txt'; });