Here is the problem I just had. I was trying to delete an image off the disk after all references to it in the database had gone - kinda like unlink(). I couldn’t work out how to access the data in the model. I need to know the filename, so I can delete it. It seems that the only way to do it is:
Define a var to hold the filename
private $_tmpImageName;
Populate this in the beforeDelete() callback
function beforeDelete() { $this->_tmpImageName = $this->read(null, $this->id); return true; }
Then access it in the afterDelete() callback, with something like this:
function afterDelete() { unlink($this->_tmpImageName['Image']['name']); return true; }
If you know of a better way, let me know.