Fix readFiles method to correctly filter .txt files by adding missing slash in path

This commit is contained in:
dhanabalan
2025-09-26 10:15:34 +05:30
parent 062f143dbb
commit 062f35cb4d

View File

@@ -62,9 +62,10 @@ class SapFileController extends Controller
// return $file !== '.' && $file !== '..' && is_file($path . $file)
// && pathinfo($file, PATHINFO_EXTENSION) === 'txt';
// });
$files = array_filter(scandir($path), function($item) use ($path) {
return is_file($path . $item) && pathinfo($item, 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';
});
if (empty($files)) {
return response()->json([