kaleopter's avatar

File not found at path with maatwebsite/excel

Hello!

I want to import xls/xlsx files to the DB.

My file is "10125320181127Alaia.xlsx".

Firstly, I'm uploading the file to the server. Now it is in the public/excel_products/10125320181127Alaia.xlsx - I see it and I can open it.

Secondly, I want to import it, and my code is:

public function ExcelImport($id)
    {
        $excel = ProductExcel::findOrFail($id);
        Excel::import(new ProductsImport, asset('excel_products/'.$excel->name));
        // ...
    }

($excel->name is "10125320181127Alaia.xlsx").

And every time I have an error:

League \ Flysystem \ FileNotFoundException
File not found at path: http:/idealstore2.local/excel_products/10125320181127Alaia.xlsx

I can open this file using

public function show($id)
    {
        $excel = ProductExcel::findOrFail($id);
        return redirect()->to(asset('excel_products/'.$excel->name));
    }

but not in maatwebsite/excel.

Maybe I may change something in the config/filesystems.php, I didn't touch it.

Thanks for yout help :)

0 likes
3 replies
ahmeddabak's avatar

in my system the excel file is in storage/app/address.xlsx

and i use it in my app by just writing

Excel::toCollection(null, 'address.xlsx', 'local');
andylord565's avatar

Try this:

Excel::import(new ProductsImport, public_path('excel_products/'.$excel->name));

Please or to participate in this conversation.