Refactor readFiles method to improve .txt file filtering logic
This commit is contained in:
@@ -58,9 +58,14 @@ class SapFileController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Filter only .txt files
|
// Filter only .txt files
|
||||||
$files = array_filter($allFiles, function($file) use ($path) {
|
// $files = array_filter($allFiles, function($file) use ($path) {
|
||||||
return $file !== '.' && $file !== '..' && is_file($path . $file)
|
// return $file !== '.' && $file !== '..' && is_file($path . $file)
|
||||||
&& pathinfo($file, PATHINFO_EXTENSION) === 'txt';
|
// && 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';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user