Example details: Nodejs saves the file sent by payload, nodejspayload

Source: Internet
Author: User

Example details: Nodejs saves the file sent by payload, nodejspayload

1: accept files

Http://stackoverflow.com/questions/24610996/how-to-get-uploaded-file-in-node-js-express-app-using-angular-file-upload

You can use the following third-party Libraries

• Busboy and connect-busboy
• Multiparty and connect-multiparty
• Formidable
• Multer

2: Save the file

Ps: nodejs get/request

Irrigation comment example:

Var http = require ('http'); var querystring = require ('querystring'); var postData = querystring. stringify ({content: 'Good reference', cid: 348}); var options = {hostname: 'www .imooc.com ', port: 80, path:'/course/docomment ', method: 'post', headers: {'Accept ': 'application/json, text/javascript, */*; q = 100', 'Accept-encoding': 'gzip, deflate ', 'Accept-Language': 'zh-CN, zh; q = 100', 'connection': 'Keep-alive', 'content-Length ': PostData. length, 'content-type': 'application/x-www-form-urlencoded; charset = UTF-8 ', 'cooki': 'imooc _ uuid = average; imooc_isnew_ct = 1452475309; IMCDNS = 0; loginstate = 1; apsid = Success Certificate % 3DZD; PHPSESSID = 1uunfnq1rdhup7tudcre36l8h1; invalid player. qualityLabel = é ...; Cvde = 415454113f947-13; region = Hangzhou; region = 1452579983; imooc_isnew = 2', 'host': 'www .imooc.com ', 'origin': 'http: // www.imooc.com ', 'Referer': 'http: // your (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/123456 ', 'X-Requested-with': 'xmlhttprequest '} var req = http. request (options, function (res) {console. log ('status: '+ res. statusCode); console. log ('headers: '+ JSON. stringify (res. headers); res. on ('data', function (chunk) {console. log (Buffer. isBuffer (chunk); console. log (typeof chunk) ;}); res. on ('end', function () {console. log ('comment complete') ;};}); req. on ('error', function (e) {console. log ('error: '+ e. message) ;}); req. write (postData); req. end ();

Articles you may be interested in:
  • Php xml error parsing SOAP payload on line 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.