Iam trying to delete an image file but its giving error that call to a member function delete() on string.
This is my code:
public function destroy($id) { $element = Element::find($id); $destination = 'public/images/'.$element->imagen; if(File::exists($destination)){ File::delete($destination); } $destination->delete(); return redirect()->route('elements.index'); } }
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra.
© 2025 by CodeBloom Education Ltd