cakephp-upload: Files stored in non-static paths cannot be deleted.
I’ve just inherited a project that uses the upload behavior, I have no experience with it yet, so please bear with me in case that might somehow be the intended behavior.
The behavior seems to generate the path of the file to delete dynamically, based on the current configuration, despite the docs saying that in order to be able to delete files at all, the records would need to have a column that holds the path of the file.
When using a path that contains non-static elements like for example {year}, {month}, {day}, files cannot be deleted at a later point where those values won’t be the same anymore as at the point where the record was created.
For example yesterday webroot{DS}files{DS}{month}{DS}{day} would have translated to webroot/files/08/27 where as today it would be webroot/files/08/28, and thus deleting a file today that was uploaded yesterday won’t work.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 17 (6 by maintainers)
As a workaround for now I’m using a custom path processor that prefers the entity value over path generation.
That requires some additional security so that user input cannot slip in for the field, but that aside it works OK.