您好,欢迎访问一九零五行业门户网

实例详解Nodejs 保存 payload 发送过来的文件_node.js

1:接受文件
http://stackoverflow.com/questions/24610996/how-to-get-uploaded-file-in-node-js-express-app-using-angular-file-upload
可以用下列的第三方库
•busboy and connect-busboy
•multiparty and connect-multiparty
•formidable
•multer
2:保存文件
ps:nodejs get/request
灌水评论示例:
var http = require('http');var querystring = require('querystring');var postdata = querystring.stringify({content: '不错不错',cid: 348});var options = {hostname: 'www.imooc.com',port: 80,path: '/course/docomment',method: 'post',headers:{'accept':'application/json, text/javascript, */*; q=0.01','accept-encoding':'gzip, deflate','accept-language':'zh-cn,zh;q=0.8','connection':'keep-alive','content-length':postdata.length,'content-type':'application/x-www-form-urlencoded; charset=utf-8','cookie':'imooc_uuid=791e8f39-5d06-433a-831f-909fa85acdd3; imooc_isnew_ct=1452475309; imcdns=0; loginstate=1; apsid=a0nwqzm2rkmzm2ndk0nwfkotc5nmqzyzbkntuymgmaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaamjc0njc4maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadbly2y5zjjizgnjztflztjmmjkwzte2y2m4ywe4mwe49qotvvudk1y%3dzd; phpsessid=1uunfnq1rdhup7tudcre36l8h1; jwplayer.qualitylabel=高清; cvde=569454113f947-13; hm_lvt_f0cfcccd7b1393990c78efdeebff3968=1452475311,1452561427; hm_lpvt_f0cfcccd7b1393990c78efdeebff3968=1452579983; imooc_isnew=2','host':'www.imooc.com','origin':'http://www.imooc.com','referer':'http://www.imooc.com/comment/348','user-agent':'mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, like gecko) chrome/45.0.2454.99 safari/537.36','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('评论完毕');});});req.on('error', function(e) {console.log('error: ' + e.message);});req.write(postdata);req.end();
其它类似信息

推荐信息