That's normal, uploading doesn't replace automatically the previous image. You have to delete the previous one manually.
Dec 22, 2022
5
Level 1
Image Update
Hello, When im editing an image it's uploading a new image without remove the old one, I've tried a lot but nothing happend
public function showEditModal($id)
{
$this->categories = Category::findOrFail($id);
$this->category_name = $this->categories->category_name;
$this->oldImage = $this->categories->category_image;
$this->isEditMode = true;
$this->showingPostModal = true;
}
public function updatePost()
{
$this->validate([
'category_name' => 'required',
]);
$image = $this->categories->category_image;
if($this->category_image){
$image = $this->category_image->store('public/category_image');
}
$this->categories->update([
'category_name' => $this->category_name,
'category_image' => $image
]);
$this->reset();
}
Here is my code, Any Help please ?
Please or to participate in this conversation.