Sails.js form post not submitting any data

后端 未结 5 1792
借酒劲吻你
借酒劲吻你 2021-01-05 19:32

Recently I came to face an unusual problem while posting a form. The form post works fine when there is no attachment or the attachment image file size is less than 100kb. B

相关标签:
5条回答
  • 2021-01-05 19:58

    had the same problem, turns out that the order of the inputs matter, says right here on the github skipper page

    It is important to realize that the benefit above(Text Parameters) relies on a crucial, simplifying assumption: that user agents send any text parameters before the first file parameter in the multipart HTTP request body. For instance, in an HTML form that means putting all of your tags after the other inputs. If you don't want to lay your form out that way, you'll want to use AJAX to submit it instead

    0 讨论(0)
  • The req.param method is used to get the url parameters, body parameters, and query parameters. (reference)

    if you're using multipart/form-data to upload files, Sails use skipper to parse the data, you can simply get the file like following

    req.file('name').upload(function (err, uploadedFiles){
      if (err) return res.send(500, err);
      return res.send(200, uploadedFiles);
    });
    
    0 讨论(0)
  • 2021-01-05 19:59

    With skipper, you have to put all your inputs files at the end of the form. Otherwise it could bug-out.

    0 讨论(0)
  • 2021-01-05 19:59

    I would suggest checking the official file upload documentation from sails....

    http://sailsjs.org/#!/documentation/concepts/File-Uploads

    I followed the steps and it works for me (on sails v 0.11). Perhaps you missed something along the way?

    0 讨论(0)
  • 2021-01-05 20:06

    better use blueimp jquery file upload plugin.. it have multiple features it may help you.

    0 讨论(0)
提交回复
热议问题