Welcome Guest, Not a member yet? Register   Sign In
How to display uploaded file from writable/uploads
#2

This may get you going in the right path.

PHP Code:
// 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($handle1000",")) !== 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');
    }

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
RE: How to display uploaded file from writable/uploads - by InsiteFX - 06-17-2025, 09:35 PM



Theme © iAndrew 2016 - Forum software by © MyBB