Laravel从上传中获取保存文件的路径

I have a laravel upload for file (along with other data that is passed to the database) Everything works. But I just can't figure out how to save the path of the file that is saved.

Here is my controller function:

public function store(Request $request)
{
    request()->validate([
        'name'              => 'required',
        'logo'              => 'nullable',
        'original_filename' => 'nullable',
    ]);

    //This is where the file uploads?
    if ($request->hasFile('logo')) {
        $request->file('logo')->store('carrier_logo');
        $request->merge([
            'logo'              => '',//TODO: get file location
            'original_filename' => $request->file('logo')->getClientOriginalName(),
        ]);
    }

    Carrier::create($request->all());
    return redirect()->route('carriers.index')->with('toast', 'Carrier created successfully.');
}

The thing I want to achieve: I want logo to fill with something like carrier_logo/ZbCG0lnDkUiN690KEFpLrNcn2exPTB8mUdFDwAKN.png

The thing that happened every time I tried to fix it was that it placed the temp path in the database. Which ended up being something in the PHP install directory.

Just assign result to variable:

$path = $request->file('logo')->store('carrier_logo');

According to docs

Then you can do with $path variable whatever you want.

just assign the value like this.

 $location=base_path('img/'.$filename);

and save it in db.

You could do this:

For FileName

$fileName = $request->file('test')->getClientOriginalName();

OR

$fileName = $request->user()->id.'.'.$request->file('logo')->getClientOriginalExtension();

$imageDirectory = 'logo_images';

$path = $request->file('logo')->storeAs($imageDirectory, $fileName);
dd($path);