Deleting/Updating a file already present on the database
Building a laravel app, User can create multiple post & can upload only 1 image. In case he wishes to update later, he can do it easily, but if in case he completely wants to remove it, how this will take place?
You make an ajax, or post request to your server hitting a specific url lie:
`user/{user}/image/delete``
this will then call the controller function deleteUserImage
public function deleteUserImage(User $user) {
$user->image = '' ; // or set it to default image what ever
$user->save();
// then here you probably remove the file from your server
return response('success');
}