I am using :
"ejs": "^2.5.6", "express": "^4.14.0", "express-validator": "^3.2.0", "multer": "^1.3.0",
My form is :
<form id="offer-form" role="form" enctype="multipart/form-data" action="/subfolder/86" method="POST">
<input type="text" name="name"/>
<input type="file" name="images"/>
<button type="submit">Submit</submit>
</form>
My server route:
var path = require('path');
var express = require('express');
var bodyParser = require('body-parser');
var expressValidator = require('express-validator');
var osmodule = require('../../osmodule');
var Multer = require('multer');
var request = require('request');
const multer = Multer({
storage: Multer.memoryStorage(),
limits: {
fileSize: 5 * 1024 * 1024 // no larger than 5mb, you can change as needed.
}
});
//Adding a new subfolder
app.post('/subfolder/:id', multer.array({ name: 'images', maxCount: 6 }), expressValidator, function (req, res, next) {
console.log("Form Submitted");
}).use(function (req, res, next) {
res.setHeader('Content-Type', 'text/plain');
res.status(404).send('Not Found ! ');
});
Normally this code should print on the console the message
Form submitted but the server is receiving nothing not even Not Found
via aidonsnous
No comments:
Post a Comment