zoukankan      html  css  js  c++  java
  • node.js模块值formidable

    模块地址:https://github.com/felixge/node-formidable

    var formidable = require('formidable'),
        http = require('http'),
        util = require('util');
    
    http.createServer(function(req, res) {
      if (req.url == '/upload' && req.method.toLowerCase() == 'post') {
        // parse a file upload
        var form = new formidable.IncomingForm();
    
        form.parse(req, function(err, fields, files) {
          res.writeHead(200, {'content-type': 'text/plain'});
          res.write('received upload:
    
    ');
          res.end(util.inspect({fields: fields, files: files}));
        });
    
        return;
      }
    
      // show a file upload form
      res.writeHead(200, {'content-type': 'text/html'});
      res.end(
        '<form action="/upload" enctype="multipart/form-data" method="post">'+
        '<input type="text" name="title"><br>'+
        '<input type="file" name="upload" multiple="multiple"><br>'+
        '<input type="submit" value="Upload">'+
        '</form>'
      );
    }).listen(8080);

    http://cnodejs.org/topic/4f5c62932373009b5c0b027b

  • 相关阅读:
    服务器响应状态码
    30
    29
    Java中参数始终是按值传递
    浅析 Java 中的继承和重写
    25
    super 关键字
    24
    Overriding
    23
  • 原文地址:https://www.cnblogs.com/youxin/p/3955706.html
Copyright © 2011-2022 走看看