douzhang6496 2019-05-21 11:08
浏览 67

Laravel 5.0使用自定义磁盘保存图像会导致错误

I am trying to upload an image and store it in a certain location using a custom disk defined in the filesystems like this:

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

In my controller I do this:

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

$file = $image->getClientOriginalName();

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

But I get the following error:

ErrorException in FilesystemManager.php line 230:

call_user_func_array() expects parameter 1 to be a valid callback, class 'Illuminate\Filesystem\FilesystemAdapter' does not have a method 'createDriver'

I am not sure what I am doing wrong here

  • 写回答

1条回答 默认 最新

  • du21064 2019-05-21 11:36
    关注

    Second argument of put method is the file content, why are you passing the original name?

    See Official Storage doc

    Change with that :

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

报告相同问题?

悬赏问题

  • ¥50 三种调度算法报错 采用的你的方案
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败