I am trying to use the composer package league/csv in laravel 5.
In my controller there is the following use statement:
use League\Csv\Reader;
Then there is the following function:
public function import (Request $request)
{
if ($request->isMethod('post'))
{
$validatedData = $request->validate([
'csv' => 'required|mimetypes:text/comma-separated-values,text/plain|mimes:csv,txt',
]);
if ($request->file('csv') && $request->file('csv')->isValid())
{
$file = $request->csv->path();
$csv = new Reader($file);
echo'<pre>';var_dump($csv);exit;
}
}
}
The reader is loaded but I got the following error message:
Call to protected League\Csv\AbstractCsv::__construct() from context 'App\Http\Controllers\MyController'
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire