I have a upload model - contains images uploaded by the user.
Inside the controller, I call:
$this->Upload->delete($id);
Which is great for deleting a record from the database, but I would also like to delete the corresponding image file.
I tried a lot of different things with different variables..etc and found this link on a similar question, but - nothing works - I can’t even delete it using any of these attempts:
function afterDelete() {
unlink('/img/uploads/rest_logo.jpg');
unlink('app/webroot/img/uploads/rest_logo.jpg');
unlink('/app/webroot/img/uploads/rest_logo.jpg');
unlink('img/uploads/rest_logo.jpg');
unlink(WWW_ROOT . 'img/uploads/rest_logo.jpg');
unlink(WWW_ROOT . '/img/uploads/rest_logo.jpg');
return true;
}
Obviously, I want to change it as a dynamic file name, but at the moment I can’t even delete it when it hardcodes all possible paths that I can think of.
Is there any way to check what happens in this? Like an echo or ... anything?
Any help or direction is appreciated.