大小网站导入在 ubuntu 中不起作用

Maatwebsite import doesnt work in ubunutu

当我尝试在 Ubuntu 中的服务器上使用 Maatwebsite 3.1 版本导入 excel sheet 时,出现此类错误。

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.

控制器

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

但是相同的导入 excel 代码在我的本地 windows 机器上工作正常。 我上传的每个代码和文件都是相同的。但在本地和服务器中的工作方式不同。谁能帮帮忙

所以问题出在 getRealPath() 上。 最初我试图通过

获取路径
$path = $request->file('mcafile')->getRealPath();

但现在我通过将它存储到临时文件并从那里检索路径并将其发送到函数来更改它。 像这样,

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

enctype="multipart/form-data" 添加到您的表单中

试试这个:

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