Maatwebsite import doesnt work in ubunutu

10,872

So the issue was with the getRealPath(). Initially I was trying to get the path by,

$path = $request->file('mcafile')->getRealPath();

But now I changed it by storing it to a temp and retrieve the path from there, and send it to the function. Like this,

$path1 = $request->file('mcafile')->store('temp'); 
$path=storage_path('app').'/'.$path1;  
$data = \Excel::import(new UsersImport,$path);
Share:
10,872

Related videos on Youtube

Oops
Author by

Oops

Code is poetry :)

Updated on June 04, 2022

Comments

  • Oops
    Oops almost 2 years

    When I try to import an excel sheet using Maatwebsite 3.1 version on server which is in Ubuntu, I am getting such type of error.

    Error:

    Maatwebsite \ Excel \ Exceptions \ NoTypeDetectedException

    No ReaderType or WriterType could be detected. Make sure you either pass a valid extension to the filename or pass an explicit type.

    Controller

    $path = $request->file('mcafile')->getRealPath();
    $data = \Excel::import(new UsersImport,$path);
    

    But the same import excel code works fine in my local windows machine. Every code and file that I upload are same. But works different in local and in server. Can anyone please help.