Hi @johnny! It so nice to be back in using GroceryCRUD
.
This version that I am currently working on is still on version 2.7.9.
I created a callback that was able to delete the uploaded file:
function deleteAccessFile($file)
{
$filePath = $_SERVER['DOCUMENT_ROOT'].'/'.FOLDERNAME."/assets/uploads/$file";
if (file_exists($filePath)) {
// Use unlink() function to delete a file
if (!unlink($filePath)) {
$message = ("$filePath cannot be deleted due to an error.");
} else {
$message = ("$filePath has been deleted.");
}
} else {
$message = "The file $filePath does not exist.";
}
return $message;
}
Currently, I use this before the deletion of the record:
$crud->callbackBeforeDelete(function ($stateParameters) {
$file = $this->m_FileProcessing->getFileName($stateParameters->primaryKeyValue);
$this->deleteAccessFile($file);
return $stateParameters;
});
I hope it helps someone too 