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
I tried with your solution, it seemed it didn't work on my machine. Client couldn't get the response after I put this line this.emit('error');
within form.on section. It seemed my program was blocked. it meant you couldn't call your upload method twice. the second call wasn't executed since your program was blocked by this line: this.emit('Error');
already.
upload:function(req, res) {
var form = new multiparty.Form();
form.on('error', function(message) {
res.send('Not Okay');
});
form.on('part', function(part) {
console.log('enter form on');
this.emit('Error');
res.send('Not Okay');
});
form.on('close', function(){
res.send('Not Okay');
});
form.parse(req);
}
The only solution I found was call part.resume();
within form.on section. it can consume your upload file on your server without touching your disk. but it will consume your network and server resources. Anyway, it's far better than program was blocked situation. That is why I'm keeping looking for another better way to resolve it.