Kshitij Sinha
Kshitij Sinha

Reputation: 59

Is there a way to handle the onClick for the delete button in Antd Upload?

Antd upload delete button

The file upload works fine. The way I have implemented the upload is that it pushed the file to a 'temp' folder. What I want is when someone clicks the delete (trash icon), I want to capture that and delete the remote file as well.

Is there any handler/onChange function for that?

Upvotes: 0

Views: 4284

Answers (1)

Scorpion-Prince
Scorpion-Prince

Reputation: 3634

The Antd Upload control has an onRemove() callback which sends the file. This is from their documentation:

onRemove: A callback function, will be executed when removing file button is clicked, remove event will be prevented when return value is false or a Promise which resolve(false) or reject

So, you can wire up the call to remove the remote file in the onRemove() callback, and if that call fails (promise is rejected), the file will not be removed from the upload control.

Upvotes: 3

Related Questions