Refactor readFiles method to dynamically set file path and improve file handling
This commit is contained in:
@@ -120,9 +120,11 @@ class SapFileController extends Controller
|
||||
// 'files' => $data,
|
||||
// ]);
|
||||
|
||||
$fileName = 'RMGLAS02-1725800-1.txt';
|
||||
//$fileName = 'RMGLAS02-1725800-1.txt';
|
||||
$fileName = array_values($files)[0];
|
||||
$filePath = $path . '/' . $fileName;
|
||||
|
||||
$lines = file($fileName, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
$lines = file($filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
if (!$lines) {
|
||||
return response()->json(['status' => 'ERROR', 'message' => 'File is empty'], 400);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user