0

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.

Elliott Coe
  • 543
  • 3
  • 6
  • 18
  • Try checking if the `fopen` is working correctly by adding an if statement `if (($handle = fopen($file, "r")) !== FALSE)` also just to be safe, use another variable for path and file handler – Alpha Olomi Jul 26 '22 at 11:00
  • Does this answer your question? [How can I read from files in UTF-16LE encoding in PHP?](https://stackoverflow.com/questions/27551099/how-can-i-read-from-files-in-utf-16le-encoding-in-php) – JosefZ Jul 26 '22 at 15:58

0 Answers0