【问题标题】:Laravel 5.0 saving image with custom disk result in errorLaravel 5.0 使用自定义磁盘保存图像导致错误
【发布时间】:2019-05-21 19:50:51
【问题描述】:

我正在尝试使用文件系统中定义的自定义磁盘上传图像并将其存储在特定位置,如下所示:

'blockcontentimages' => [
    'driver' => 'local',
    'root'   => public_path() . '/static/core/img/templates',
],

在我的控制器中,我这样做:

$image = $request->file('content');

$file = $image->getClientOriginalName();

Storage::disk('blockcontentimages')->put('filename', $file);

但我收到以下错误:

FilesystemManager.php 第 230 行中的 ErrorException:

call_user_func_array() 期望参数 1 是一个有效的回调,类 'Illuminate\Filesystem\FilesystemAdapter' 没有方法 'createDriver'

我不确定我在这里做错了什么

【问题讨论】:

  • 我不认为它会解决问题,但它不应该是->put($file, $image)吗?

标签: php laravel laravel-5


【解决方案1】:

put方法的第二个参数是文件内容,你为什么要传递原名?

见Official Storage doc

随之改变:

$image = $request->file('content');
Storage::disk('blockcontentimages')->put('filename', $file);

【讨论】:

  • 我改变了它,不幸的是它给出了同样的错误
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-13
  • 2019-10-15
  • 2013-11-03
  • 1970-01-01
  • 2021-10-13
  • 1970-01-01
相关资源
最近更新 更多