From 3a115241a931a5daefdc4889a627b10edc6d6ebc Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 26 Sep 2025 10:21:07 +0530 Subject: [PATCH] Fix readFiles method to add missing slash in file path for correct .txt file filtering --- app/Http/Controllers/SapFileController.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/SapFileController.php b/app/Http/Controllers/SapFileController.php index 78785bc2a..f74af917c 100644 --- a/app/Http/Controllers/SapFileController.php +++ b/app/Http/Controllers/SapFileController.php @@ -62,10 +62,13 @@ class SapFileController extends Controller // return $file !== '.' && $file !== '..' && is_file($path . $file) // && pathinfo($file, PATHINFO_EXTENSION) === 'txt'; // }); - $files = array_filter($allFiles, function($item) use ($path) { - $fullPath = $path . '/' . $item; // Add the missing slash - return is_file($fullPath) && pathinfo($item, 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'; +}); + + + if (empty($files)) { return response()->json([