[SOLVED] Laravel Excel Import pathinfo() expects parameter 1 to be string, object given


This Content is from Stack Overflow. Question asked by Pouya

I’m using LaravelExcel and I want to load an Excel file on my project from a form, so I tried this:

use MaatwebsiteExcelFacadesExcel;

public function postDocuments(Request $request)
    try {
         Excel::import($request->file('student_list'), function ($reader) {
                foreach ($reader->toArray() as $row) {
    } catch (Exception $e) {

But I get this error when uploading:

pathinfo() expects parameter 1 to be string, object given

enter image description here

So what’s going wrong here?

How can I solve this issue?


Import static method looks like this:

import(object $import, string|UploadedFile $filePath, string $disk = null, string $readerType = null)

As you can see, first parameter import class and second parameter is file or path.

If you use latest version, in my opinion in case your code is wrong.

Maybe this page is helpful for this issue => https://docs.laravel-excel.com/3.1/imports/basics.html

This Question was asked in StackOverflow by Pouya and Answered by coder2 It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?