This thread is resolved. Here is a description of the problem and solution.
Problem:
Delete the files uploaded using CRED forms
Solution:
You can not delete the uploaded file. This is a drawback as there is no way to identify whether or not those media files have been used elsewhere on the site at that point. For now, these Media Library items will remain stored in your site files.
I have a front-end form which allows attaching files to the CTP. I noticed that when I upload a file and than remove it and upload another one before submitting the form:
1. the first file is still on a server
2. the media post is created from the first file
How to prevent it?
EDIT:
I noticed that prior the form is submitted, the media posts are marked as CRED Auto Draft. But if I remove and upload couple of files before I submit the form, after form submission all the "auto drafts" are attached to the same CTP, not only the last one. Is it desired behavior? It's like all the unwanted files before the form is submitted remain in the media library.
Hello. Thank you for contacting the Toolset support.
Well - unfortunately - we do not automatically remove attachments that were added to those draft posts. The reason is that we have no way of knowing whether those images have been used elsewhere on the site. So for now, the images will remain in the Media Library indefinitely.
As said - this is expected behavior and there is no solution to it as of now. We have internal ticket with our Devs and its already known to us. We will try to improve this in near future when our Devs find some way and better solution to handle this situation.
When I upload a file before I submit the form, the file is attached to the media library as auto draft. I read somewhere on the forum that these drafts are automatically removed after some time, is that correct? I don't think that these drafts would be used anywhere on a website, as these are actually temporary files, not even confirmed (submitted). So I think that only these files uploaded along with a form should be converted from auto drafts to proper attachments in media library, not the ones that were deleted from the form before it was submitted (and now they become proper attachments even though they were deleted before the form was submitted).
When I upload a file before I submit the form, the file is attached to the media library as auto draft. I read somewhere on the forum that these drafts are automatically removed after some time, is that correct?
=> Yes, CRED Auto Draft posts are deleted after 4 hours.
I don't think that these drafts would be used anywhere on a website, as these are actually temporary files, not even confirmed (submitted). So I think that only these files uploaded along with a form should be converted from auto drafts to proper attachments in media library, not the ones that were deleted from the form before it was submitted (and now they become proper attachments even though they were deleted before the form was submitted).
==> Yes - this is a drawback as I tried to explain that there is no way to identify whether or not those media files have been used elsewhere on the site at that point. For now, these Media Library items will remain stored in your site files.