问题
I was wondering how can I empty the files inside on dropzone after it is already saved in the server and the database? My problem is when I submitted it maintain the files on the dropzone and even on the modal closed. I wish I can give a code about emptying the dropzone but I don't have any idea so instead I will leave the code of dropzone and onsubmit.
The code for onsbumit
onSubmit() {
debugger
form.Status=0;
form.isActive=true;
return(form.Key > 0 ? this.creater : this.creater).call(this, form);
return false;
}
the code for ondrop
onDrop(acceptedFiles, e) {
debugger
console.log('Received files: ', acceptedFiles);
this.setState({files: acceptedFiles});
const req = request.post('http://localhost:8933/api/upload/post');
acceptedFiles.forEach(file => {
req.attach(thisUuid , file);
});
req.end(callback);
}
回答1:
Dropzone has a method removeAllFiles
that deletes all files that are currently in dropzone instance (the usage is something like Dropzone.removeAllFiles()
).
You'd want to call in the callback that is invoked when you have finished uploading your files to the server.
You might also be interested this tutorial on how to delete files.
来源:https://stackoverflow.com/questions/45140620/how-to-empty-the-dropzone-modal-after-submitted-in-reactjs