windows - Maatwebsite 导入在 ubuntu 中不起作用

标签 windows ubuntu import laravel-5.8 maatwebsite-excel

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

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);

但是相同的导入 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);

关于windows - Maatwebsite 导入在 ubuntu 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57105889/

相关文章:

ubuntu - 如何将 BCDEdit 恢复为默认值?

typescript - 有没有一种方法可以使用泛型参数导入类型?

r - 如何避免 "cannot find -lR"在 Windows 上安装 R 包

python - 如何将 timeit 与包含 EOL 字符的命令一起使用?

linux - 无法通过端口转发从主机连接到 Vagrant (ubuntu/trusty64)

linux - vmWare Server 可以安装在 X-less 主机上吗?

mysql - b2evolution 到 WordPress 移动和转换

azure - 如何在 Terraform 的状态下导入整个 Azure 资源组?

windows - 没有管理员权限的用户的独立 Mercurial(或其他 SCM)客户端?

c++ - 可能的 : Program executing Qt3 and Qt4 code?