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

后端 未结 8 1081
[愿得一人]
[愿得一人] 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:07

    I dont know if the thread is still waiting for a answer but in case that is, you can prevent file upload in formidable by setting form.maxFileSize to zero. If the codition are meet, he will send a error event saying that the maxFileSize exceeded.

    fileUpload = false
    form = new require("formidable").IncommingForm()
    
    if(fileUpload)
      //Do stuff here
    else
      form.maxFileSize = 0
    

提交回复
热议问题