Sails.js message does not send any data

I recently encountered an unusual problem submitting a form. A form post works fine when there is no attachment or the attachment image file size is less than 100 KB. But when I tried to upload a file larger than 100 KB, not a single item in the form will be sent / sent. When I console.log() value it gives is undefined. I can not understand what is causing the problem. Errors are not displayed on the console screen. Can anyone help with this problem?

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

The result I get is undefined .

I am using sails v0.10.5 for windows 8.1. I use postgres as my database.

+6
source share
5 answers

With the skipper, you must put all of your input files at the end of the form. Otherwise, this may result in an error.

+7
source

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

It is important to understand that the above advantage (text parameters) is based on a crucial, simplifying assumption: user agents send text parameters before the first file parameter in a multi-page HTTP request. For example, in an HTML form, which means placing all your tags after other inputs. If you do not want to place your form in this way, you will want to use AJAX instead.

+3
source

The req.param method req.param used to get url parameters, body parameters, and query parameters. ( link )

if you use multipart/form-data to upload files, Sails uses skipper to analyze the data, you can simply get the file as follows

 req.file('name').upload(function (err, uploadedFiles){ if (err) return res.send(500, err); return res.send(200, uploadedFiles); }); 
+2
source

it is better to use the plugin to download the blueimp jimpery file. It has several features that can help you.

+1
source

I would suggest checking the official documentation for downloading files from sails ....

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

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

0
source

Source: https://habr.com/ru/post/985569/


All Articles