Sails.js form post not submitting any data

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. But when I tried to upload a file larger than 100kb no element in the form is being posted/submitted. When I console.log() the value it gives undefined. I can't understand what is causing the problem. No errors are shown on console screen. Can anyone help with this problem?

var name = req.param('name');

The result i get is undefined.

I'm using sails v0.10.5 on windows 8.1. I'm using postgres as my database.



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


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


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);

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


I would suggest checking the official file upload documentation from sails....!/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?


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.