I am complete Newbie to Node.js.I just want to learn upload and showing images using ajax like i do in php.I found most of the tutorials tough for me.To get started I have tried using this code
var express = require("express");
var app = express()
var bodyParser = require('body-parser')
//all environment
app.use(bodyParser())
var form = "<!DOCTYPE HTML><html><body>" +
"<form method='post' action='/upload' enctype='multipart/form-data'>" +
"<input type='file' name='image'/>" +
"<input type='submit' /></form>" +
"</body></html>";
app.get('/', function (req, res){
res.writeHead(200, {'Content-Type': 'text/html' });
res.end(form);
});
/// Post files
app.post('/upload', function(req, res) {
console.log('Hello world');
console.log(req.files);
});
app.listen(8080)
But am getting UNDEFINED for req.files.can anybody tell why?.Please forgive me if its a stupid question.And also help with some resources.Thank you in Advance.