Error: Call to a member function storeAs() on string

Error: Call to a member function storeAs() on string

public function cadastraAutomovelHomeAdd(Request $request)
{
    $file = $request->arquivo;
    $upload = $request->arquivo->storeAs('products', 'novonomeaffffff.jpg');
    exit();
}

表格

<form method='post' action='/cadastrar' enctype="multipart/form-data">
    {{ csrf_field() }}
    <div>
        <h5>Placa do Veículo:</h5>
    </div>
    <input type="file" class="form-control" name='arquivo' required placeholder="IMAGEM DO VEÍCULO">
    <input type='submit'/>
</form>

路线

Route::post('/cadastrar','Automovel@cadastraAutomovelHomeAdd');

我提交表单,但出现以下错误。

Call to a member function storeAs() on string

您需要将其包装为文件才能访问文件方法,例如:

$upload = $request->file('arquivo')->storeAs('products', 'novonomeaffffff.jpg');

https://laravel.com/docs/master/filesystem#storing-files