form.parse()永远不会调用,当我删除bodyparser然后它,我的会话变量通过错误,如何让它工作
logcat的
不建议使用write(字符串,编码,偏移量,长度)。使用 write(string [,offset [,length]] [,encoding])。 events.js:85 扔掉//未处理的错误'事件^错误:ENOENT,打开 ' /home/pitu/CODING/NODE-PROJECTS/chichat/files/a88b7a4fbd8cb31e276ef60c8e934d2d.png' 在错误(本机)
app.js文件
var express = require('express'),
app = express(),
http = require('http'),
path = require('path'),
fs = require('fs'),
mysql = require('mysql'),
server = http.createServer(app),
//events = require('events'),
//path = require('path'),
//url = require('url'),
//Create a new store in memory for the Express sessions
sessionStore = new express.session.MemoryStore(),
passport = require('passport'),
flash = require('connect-flash'),
useragent = require('express-useragent'),
cookieParser = express.cookieParser('hjnjnm'),
io = require('socket.io').listen(server);
// configuration ===============================================================
// connect to our database
require('./config/passport')(passport); // pass passport for configuration
app.configure(function() {
// set up our express application
app.use(express.logger('dev')); // log every request to the console
app.use(cookieParser); // read cookies (needed for auth)
app.use(useragent.express());
app.use(express.methodOverride());
app.use(express.bodyParser({keepExtensions:true,uploadDir:path.join(__dirname,'/files')}));
app.set('view engine', 'ejs'); // set up ejs for templating
// required for passport
app.use(express.session({store: sessionStore,key: 'myuser.sid',cookie: { secure: false,maxAge:3600000}} )); // session secret1
app.use(passport.initialize());
app.use(passport.session()); // persistent login sessions
app.use(flash()); // use connect-flash for flash messages stored in session
app.use(express.static(path.join(__dirname, 'public')));
app.all('*', function(req, res, next)
{
res.header("Access-Control-Allow-Origin", "*");
res.set('Access-Control-Allow-Methods', 'GET, POST');
res.header("Access-Control-Allow-Headers", "X-Requested-With");
next();
});
});
require('./app/socket/mainSocket.js')(app,io,sessionStore,cookieParser);
// routes ======================================================================
require('./app/controller.js')(app, passport,io); // load our routes and pass in our app and fully configured passport
// launch ======================================================================
server.listen(8080);
我应该使用什么,bodyparser或强大,我想上传大文件到服务器,哪一个将满足我的需要,最小的开销。 任何帮助将不胜感激,谢谢