Upload file and remove the old

I have a page to insert record, that works perfectly, with a file field for uploading an PDF (not required)
Then I have a page to update records
My problem, which I could not solve with Wappler, occurs when a new PDF file is chosen for upload
I need to delete the old file from the server, if it exists
I can’t understand if I do to delete it before or after the new upload and how is it better to set the sequence of actions?
Can anyone help me?
Thank you

Community Page
Last updated: