Итак, в конечном итоге это
Я добавил эти методы в update-profile-photo.js
methods: {
updateProfilePhoto() {
axios.post('/settings/profile/details/profile-picture', this.gatherFormData())
.then(
() => {
console.log('Profile picture updated');
Bus.$emit('updateUser');
self.form.finishProcessing();
},
(error) => {
self.form.setErrors(error.response.data.errors);
}
);
},
gatherFormData() {
const data = new FormData();
data.append('photo', this.$refs.photo.files[0]);
return data;
}
}
И мой контроллер выглядел так
public function updateProfilePicture(Request $request)
{
$this->validate($request, [
'photo' => 'required',
]);
// Storing the photo
//get filename with extension
$filenamewithextension = $request->file('photo')->getClientOriginalName();
//get filename without extension
$filename = pathinfo($filenamewithextension, PATHINFO_FILENAME);
//get file extension
$extension = $request->file('photo')->getClientOriginalExtension();
//filename to store
$filenametostore = $filename.'_'.time().'.'.$extension;
Storage::disk('s3_users')->put($filenametostore, fopen($request->file('photo'), 'r+'), 'public');
$url = $filenametostore;
$request->user()->forceFill([
'image_url' => $url
])->save();
return response()->json(
array(
"message" => "Profile picture was updated!",
)
);
}