How to replace document?

User uploaded document "Accepting Task" which is being shown as a document link to download upon saving as shown in the below image.

If user tries to reupload an updated document, we want to update existing document with new version instead of creating multiple instances.

In order to use the document Id in the target to replace the document in folder, it is not a specific document id that we want to replace always. User can upload any number of documents and replace them. 

If we delete the below "Accepting Task" document, it will not delete it from folder but just from database. We want to delete it from folder and create new one with what user uploads, or replace the existing document if the file name matches. how to achieve this? Please advise with a recipe.

 

  Discussion posts and replies are publicly visible