Auto delete files when deleted in FileUpload component
Hi all, I'm using the FileUpload component a lot and even got it to work properly on DigitalOcean Spaces, which is awesome! However, I cannot find an easy solution or configuration option for the component that deletes files from the storage when I delete a file in the component and save the record.
Did any of you face this issue? How did you solve it if you did?
Solution:Jump to solution
Found a solution tonight. I've created an Observer and have used the isDirty and getOriginals method to find which files would need to be deleted on the 'updating' and 'deleted' event. Then used the Storage::disk('local')->delete($file) code.
1 Reply
Solution
Found a solution tonight. I've created an Observer and have used the isDirty and getOriginals method to find which files would need to be deleted on the 'updating' and 'deleted' event. Then used the Storage::disk('local')->delete($file) code.