流明上传文件错误

Upload file error in lumen

我使用 laravelUploader 包形式 this link 来上传我的文件 .当我使用此包通过以下代码在 lumen 中发送文件时:

$file = $this->uploader->file($request->file('file'))->push(storage_path('app'));
return $this->respondCreated(['data'=>$file->getFullPath()]);

我收到类似这样的错误:

BindingResolutionException in Container.php line 752:
Target [Illuminate\Contracts\Filesystem\Factory] is not instantiable while building [Almazik\LaravelUploader\LaravelUploader].

现在我该如何解决?

使用此代码段绑定 Illuminate\Contracts\Filesystem\Factory 的实现。

$app->singleton(
    Illuminate\Contracts\Filesystem\Factory::class,
    function ($app) {
        return new Illuminate\Filesystem\FilesystemManager($app);
    }
);

Note: You can do this in your bootstrap/app.php file right after you register Almazik\LaravelUploader\FileUploaderServiceProvider.