gridform icon indicating copy to clipboard operation
gridform copied to clipboard

No answer when posting only text-fields (no files)

Open eirikfro opened this issue 10 years ago • 5 comments

Hi, I don't know if this is a formidable issue or a gridform issue, or maybe even more likely an issue with my code, but when posting a form without any files (only text fields), I get no answer. When only a file is provided everything works fine, the same when both files and fields are provided in the post. Do you have any idea what this problem might be?

var form = gridform(); //enters into the incoming form constructor (see longer down)
    assert(form instanceof formidable.IncomingForm); 
    form.parse(req, function (err, fields, files) { // this is not fired at all.....

I have tracked it down to the IncomingForm.handlePart method here:

IncomingForm.prototype.handlePart = function(part) {
...
...
    part.on('end', function() {
        console.log(value);//this prints
      self.emit('field', part.name, value);
    });
    return;

eirikfro avatar Mar 16 '14 21:03 eirikfro

I meet the same problem

mainliner avatar Apr 29 '14 06:04 mainliner

I figured out how to fix this. I believe the problem was in the formidable framework included in gridform. By installing the newest version of formidable and require this new version. Everything works fine. In addition you have to remove the assert when using, as the form is not an incoming form of the correct version anymore. I do not know if this might lead to problems down the line though.. Maybe this could be updated to work correctly in gridform aheckmann?

eirikfro avatar Apr 29 '14 08:04 eirikfro

Thanks for your help. I will try to use the newest version of formidable. And I try to fix it in a lazy way. Here is my code. At the incoming_form.js IncomingForm.prototype._initMultipart change the onEnd function to this

  parser.onEnd = function() {
    self.ended = true;
    console.log('parser on end');
    setTimeout(function(){self._maybeEnd();},0);
    //self._maybeEnd();
  };

I think this problem's reason is because the _maybeEnd function is called to fast when there is no files to upload. And the callback event is not initial , especially

.on('end', function() {
        cb(null, fields, files);

mainliner avatar Apr 29 '14 08:04 mainliner

I just published 0.1.6 with updated dependencies. please test and let me know how it goes.

aheckmann avatar May 03 '14 16:05 aheckmann

With published 0.1.7 formidable 1.0.14 and gridfs-stream: 0.5.0 This problem reapears.

I've updated to: formidable 1.0.16 and gridfs-stream: 0.5.3 all test passed and empty file posts parsed ok!

sitamet avatar Jan 08 '15 18:01 sitamet