Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
350 views
in Technique[技术] by (71.8m points)

node.js文件怎么上传啊??

新手,不太懂node,我就是前台post了个表单,用node.js写了一个接受并发送邮件的一个js文件,但是不知道怎么把这个js文件打包FTP上传到我的网站,求帮助!这是js文件的代码

var nodemailer = require('nodemailer');
var http = require('http');
var transporter = nodemailer.createTransport({
service: 'qq',  
auth: {  
  user: '[email protected]',  
  pass: 'luedtauruxbycaej' //授权码,通过QQ获取  
  
}  
});  
var server = http.createServer(function(req,res){
 if(req.url!=="/favicon.ico"){
  req.on('data',function(data){
   console.log("服务器接收到的数据: "+decodeURIComponent(data));
   var mailOptions = {  
      from: '[email protected]', // 发送者  
      to: '[email protected]', // 接受者,可以同时发送多个,以逗号隔开  
      subject:'emails', // 标题  
      //text: 'Hello world', // 文本  
      html: decodeURIComponent(data),
    };  
  transporter.sendMail(mailOptions, function (err, info) {  
  if (err) {  
    console.log(err);  
    return;  
  }  
  
  console.log('发送成功');  
  res.send('发送成功');  
});  

  });
  req.on("end",function(){
   console.log('客户端请求数据全部接收完毕');
  });
  }
 res.end();
}).listen(1337,"localhost",function(){
 console.log("listened");
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

可以参考下node.js文件上传处理示例,希望对你有帮助


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...