My approach to file attachment and handling in my main form/document is unique because I use a hidden iframe for users to dynamically upload files.
Whenever a user adds or removes a file, it undergoes a process where it gets deleted from or persisted to the database by submitting an additional form to the iframe. Following that, there is an ajax call which updates the list of files in a new gsp template without having to reload the page.
After successful validation and saving of the main form, the uploaded files are linked to it. If not, they are eventually removed at a later time.
While I am satisfied with this process, I am curious if it is considered a good approach since I constantly generate a new template instead of using JavaScript for DOM manipulation like many others do to create a dynamic feel for handling files.
The one challenge I face is figuring out how to locally hide a file from the user without deleting it from the database (without impacting the DOM). Currently, if a user deletes a file but chooses not to save the main form, the file is still permanently removed.
Any insights or suggestions would be greatly appreciated!