How to empty the dropzone modal after submitted in ReactJS?

萝らか妹 提交于 2019-12-13 08:40:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!