php - laravel - delete multiple photos with unlink path wont work
Get the solution ↓↓↓What I am trying to achieve is to delete multiple photos from one delete command, but it only delete the record from the database, but unable to delete the file in my local storage. I am trying to use unlink() method in order to make this to work. I hope somebody would enlighten me where that I made my mistake. Thank you!
Delete method
//There are 8 columns of image, the database record is wiped, but not in the local storage.
public function destroy(Gallery $gallery){
for ($i = 1; $i < 9; $i++) {
$path = storage_path('app/public/' . $gallery->image_ . $i);
if (file_exists($path)) {
@unlink($path);
}
}
$gallery->delete();
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: xmlhttprequest error flutter
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.