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