I would like to delete all files in the “Upload files” area automatically via a button. The reason for this is that I want to be able to upload new photos again in order to insert them into a new report.
Currently “files_picture” is deleted and the content in “MultiFileField” remains. I have not found anything helpful in the documentation and manually deleting all images is not an option in the long term.
Here is the view window “upload files”:
Here is the Code:
files_picture = MultiFileField('Upload files', file_types=['.png', '.jpg', '.jpeg'], max_size=499_000_000)
delete_files_picture = SetParamsButton('Bilder löschen', method='delete_uploaded_pictures')
def delete_uploaded_pictures(self, params, **kwargs):
uploaded_files = params.files_picture
if uploaded_files:
uploaded_files.clear()
return SetParamsResult({
"files_picture": uploaded_files,
})