Drag and drop file upload reset

Topic: Drag and drop file upload reset

LTMG01 free asked 3 years ago

I have a form that contains the option for users to select one of the following: "upload a file now" or "email a file later".

If the user selects the "upload a file now" option then a part of the form slides down that contains the MDB drag and drop file upload. If the user selects "email a file later" then this part of the form stays hidden.

My question/scenario is as follows: if the user first chooses to upload a file and adds that file through the drag and drop functionality, is there a way to reset the drag and drop field if that user then changes his mind and chooses to select "email a file later"? In other words, I would need to fire the same event(s) that are fired when the REMOVE button is clicked after a file was selected without actually clicking that REMOVE button. What would that/those event(s) be?

Anna Morawska staff answered 3 years ago

Hi there,

you can simulate a click event like this:

document.getElementsByClassName('btn btn-sm btn-danger')[0].click()



Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.6.1
  • Device: Any
  • Browser: Any
  • OS: Any
  • Provided sample code: No
  • Provided link: No