is there?
Oct 27, 2022
13
Level 6
remove the image from inside hosting
Hello to all dear friends We always save an image for a product in the database and delete the product after a while, but the image remains on the host. The only way to remove the image from inside hosting is to go hosting the panel, is there?
Level 8
@LoverCode My English is not good too but it's quite hard to understand your replies.
public function destroy($id)
{
$item = Product::findOrFail($id);
$imagePath = public_path().'/'.$item->image_path;
unlink($imagePath);
if ($item->delete()) {
return redirect()->route('item.index')
->with('success', 'OK');
}
return redirect()->route('item.index')
->with('error', 'Failed');
}
Please or to participate in this conversation.