简体   繁体   English

Laravel错误:在null上调用成员函数store()

[英]Laravel error: Call to a member function store() on null

When I tried to send any file I get this message 当我尝试发送任何文件时,我收到此消息

It's form in home.blade.php 它在home.blade.php中形成

<form action="{{ URL::to('/upload') }}" enctype="multipart/form-data" method="post">
      <input type="file" name="something" >
      {{ csrf_field() }}
      <button type="submit" name="button">Upload</button>
</form>

It's function inside a Controller 它在控制器内部起作用

public function store(Request $request)
{
    $path = $request->file('something')->store('upload');
    echo $path;
}

Try to change controller code like this and see the result: 尝试像这样更改控制器代码并查看结果:

public function store(Request $request) {
$path = $request->something;
echo $path;  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM