I am trying to save/upload a profile image in my Laravel 8 application. I am using the stock controller "UpdateUserProfileInformation.update" in Laravel Fortify I however keep getting this error
ErrorException Attempt to read property "image" on array
View
...
<form method="POST" action="{{ route('user-profile-information.update') }}">
@csrf
@method('PUT')
...
<input type="file" accept="image/*" id="image" name="image" />
...
Controller
public function update($user, array $input)
{
...
$fileName = time().'.'.$input['image'];
$input->image->move(public_path('uploads'), $fileName);
...
Obviously my issue is that i am trying to save an array, but I can't figure out how to isolate this single file.
CodePudding user response:
when working with files in form you should add an enctype
<form enctype="multipart/form-data" method="post" action="">
CodePudding user response:
You need to add enctype="multipart/form-data" in form tag when working with file
Replace
<form method="POST" action="{{ route('user-profile-information.update') }}">
With
<form method="POST" action="{{ route('user-profile-information.update') }}" enctype="multipart/form-data">