How to cancel user upload in Formidable (Node.js)?

后端 未结 8 1086
[愿得一人]
[愿得一人] 2021-02-07 22:14

I have been working on this problem for two days now, and I am stuck. I am using Node.js with Express, and I am trying to implement an upload form. Basically, I want the form to

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-07 23:12

    Form.pause actually will prevent browser sending more data. Call below function did it for me:

    var closeConnection = function(res, form){
        try{
        if (!res.ended){
            form.onPart=null;
            form.pause();
            res.end();
            res.ended = true;
        }
        }catch(e){console.log(e);}
    }
    

提交回复
热议问题