1
0
forked from poc/pds

Fix readFiles method to add missing slash in file path for correct .txt file filtering

This commit is contained in:
dhanabalan
2025-09-26 10:22:23 +05:30
parent 3a115241a9
commit f50fbf5771

View File

@@ -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)) {