Expressjs bodyParser and connect-form
Expressjs bodyParser and connect-form
我用连接表单上传图片。但是如果我用bodyParser()
,它就不起作用了。另一种方式,如果我不使用bodyParser,我不能上传文件?
我怎么让他们一起玩?下面是我的配置:
app.configure(function() {
app.register('.html', require('ejs'));
app.set('views', __dirname + '/../views');
app.set('view engine', 'html');
app.use(gzippo.staticGzip(__dirname + '/../public'),{ maxAge: 86400000 });
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(form({
keepExtensions: true,
uploadDir: __dirname + '/../tmp'
}));
app.use(express.cookieParser());
app.use(express.session({
secret: 'test',
cookie: { secure: true },
store: new MySQLSessionStore(client.database, client.user, client.password)
}));
app.use(expressValidator);
app.use(app.router);
app.use(express.csrf());
});
如果您使用的是最新的Express,则不需要包含Connect -form(自Connect 1.8.x以来已弃用)。
只需使用req。来获取上传的文件,Express会完成其余的工作。查看这篇文章:
http://tjholowaychuk.com/post/12943975936/connect-1-8-0-multipart-support相关文章:
- 为什么grunt contrib connect的中间件选项的第三个参数是未定义的
- Dojo:访问dijit.form.Select中单击的项目
- Selenium WebDriver and JavaScript change
- Javascript form innerHTML
- Grunt-connect在根目录之外提供静态文件
- Bootstrap Contact Form with jQuery Validation and AJAX
- Form ajax and ob_flush
- jQuery and Ajax Form Validation
- Knockoutjs and Form binding
- Facebook Connect - JavaScript and PHP SDK
- Expressjs bodyParser and connect-form
- innerHTML, <form> and Firefox
- Connect JavaScript and Ms Sql
- Form Inside li and inside Loop
- Vuzix M100 and Webrtc Error: connect failed: EHOSTUNREACH (N
- <form> and Jquery ajax error
- Nodejs and Connect "next" functionality
- onsubmit javascript and form
- jquery ajax send form.serialize, variable and array all as d
- Window.confirm and html form