首页 > 代码库 > node.js模块值formidable
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:\n\n‘); 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="http://www.mamicode.com/Upload">‘+ ‘</form>‘ );}).listen(8080);
http://cnodejs.org/topic/4f5c62932373009b5c0b027b
node.js模块值formidable
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。