I am working with Zend FW and deleting images from a form submitted in a view. I successfully delete all images name from the database, each one of them in the Array using their IDs.
What I can't solve is once the names are deleted how do I unlink each file form the folder?
I have an hidden fied as follow:
<input type="hidden" name="Image[]" value="<?php echo $this->escape($r['image']); ?>" />
And I know that In the controller I can call a file name using:
$images = $this->_getParam('image');
This is fine for one image but how do I unlink an Array of files? It is the first time that I come across this problem, please help.
I am trying to do something like this:
foreach ($images as $img) {
foreach(("/uploads/thumb}/{$img}") as $file) {
unlink($file);
}
}
I am probably doing something silly...apologies.
Taking in consideration the help from vascowhite I managed to make it work this way. the simplest and abvious really:-
foreach($images as $img) {
$file = "./uploads/thumb/$img";
unlink($file);
}