From f50fbf5771118ef54ab4e0e384fbd8d4069e8bc8 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 26 Sep 2025 10:22:23 +0530 Subject: [PATCH] Fix readFiles method to add missing slash in file path for correct .txt file filtering --- app/Http/Controllers/SapFileController.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/SapFileController.php b/app/Http/Controllers/SapFileController.php index f74af917c..7a770ed52 100644 --- a/app/Http/Controllers/SapFileController.php +++ b/app/Http/Controllers/SapFileController.php @@ -58,16 +58,10 @@ 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(scandir($path), function($item) use ($path) { - $fullPath = $path . '/' . $item; // ✅ Add missing slash - return is_file($fullPath) && pathinfo($item, PATHINFO_EXTENSION) == 'txt'; -}); - - + $files = array_filter($allFiles, function($file) use ($path) { + return $file !== '.' && $file !== '..' && is_file($path . $file) + && pathinfo($file, PATHINFO_EXTENSION) === 'txt'; + }); if (empty($files)) {