Hello im getting the following error while upload an image using laravel: "Call to a member function getClientOriginalExtension() on null".
Here is my controller:
$imageName = rand(11111, 99999) . '.' . $request->file('image')->getClientOriginalExtension();
$destinationPath = 'events';
$fileName = rand(11111, 99999) . '.' . $extension;
$upload_success = $image->move($destinationPath, $imageName);
Here is my view:
{!! Form::file('image', null, ['class' => 'form-control']) !!}
How do i save the $imageName to the pic field in my database. I tried this but it doesn't work. The field remains empty in the table.
$task=$request->user()->tasks()->create([
'name' => $request->name,
'description' => $request->description,
'location' => $request->location,
'pic' => $imageName,
]);