// In your controller or a suitable method
public function readAndDisplayCsv()
{
// Replace 'your_csv_file.csv' with the actual filename
$filePath = WRITEPATH . 'uploads/your_csv_file.csv';
if (file_exists($filePath)) {
$csvData = [];
if (($handle = fopen($filePath, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$csvData[] = $data;
}
fclose($handle);
}
// Pass $csvData to your view for display
return view('csv_display_view', ['csvData' => $csvData]);
} else {
// Handle file not found error
return $this->response->setStatusCode(404)->setBody('File not found');
}
}