I am trying to open a file in Laravel using the following code:
$file = Storage::path('email_ingested_data/data/Report.csv');
$file = fopen($file, 'r');
$csv = fgetcsv($file);
dd($csv);
And the output seems to be a single item array with the following contents:
ÿþD\x00a\x00t\x00e\x00\t\x00A\x00d\x00 \x00u\x00n\x00i\x00t\x00\t\x00A\x00c\x00t\x00i\x00v\x00e\x00...
When I open the CSV in excel or even in my IDE it opens without any issues.
fopen
is working correctly by adding an if statementif (($handle = fopen($file, "r")) !== FALSE)
also just to be safe, use another variable for path and file handler – Alpha Olomi