How to delete multiple uploaded images in folder using PHP
one text
Solution:
I have Solve issues First get all values in database and using explode
function use the count
database columns values and use finally for loop.
This My Code:-
This code means is get values in database.
$data = $this->select_where('catalog_inventory', $where);
$res = $data->fetch_object();
$image = $res->upload_file;
$allimages = explode(",", $image);
$countallimages = count($allimages);
After get multiple values and values run the looping
for ($i = 0; $i < $countallimages; $i++) {
if (file_exists("product_images/" . $allimages[$i]) == false) {
echo "error ";
exit();
}
}
for ($i = 0; $i < $countallimages; $i++) {
$path = "product_images/" . $allimages[$i];
if (empty($path)) {
} else {
unlink($path);
}
}
Thanks ...
Source