var request = require('request');
var req = request.post("http://xxxxx.com/api/image", callback)
var form = req.form();
form.append("id","123456");
form.append("FileData",fs.createReadStream(path.join(__dirname, 'doodle.png'));
//使用req.form() 这种方式上传content-type=form-data类型的不成功,通过抓包工具抓不到数据 content-length = 0
//请高手支招,在线等!!!!!!
let fsStream = request.post(url); fsStream.on('end', () => { //上传完成 }); //将要上传的文件pipe到fsStream file.pipe(fsStream);
简易上传代码。