title: TypeError: Cannot read property 'image' of undefined
body: <p>There is something wrong in my source code but I'm not able to figure out what - please help. I was looking for some solutions found some and updated source code according them but didn't help.</p>
  
  <pre><code>var express = require('express');
  var fs = require('fs');
  var bodyParser  = require('body-parser');
  var app = express()
  
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  
  var form = "&lt;!DOCTYPE HTML&gt;&lt;html&gt;&lt;body&gt;" +
  "&lt;form method='post' action='/upload' enctype='multipart/form-data'&gt;" +
  "&lt;input type='file' name='image' id='image'/&gt;" +
  "&lt;input type='submit' /&gt;&lt;/form&gt;" +
  "&lt;/body&gt;&lt;/html&gt;";
  
  
  
  app.get('/', function(req, res){
      res.writeHead(200, {'Content-Type': 'text/html'});
      res.end(form);
  
  });
  
  app.post('/upload', function(req, res){
      fs.readFile(req.files.image.path, function(err, data){
  
          var imageName = req.files.image.name
          if(!imageName){
              console.log("There was an error");
              res.redirect('/');
              res.end();
          }else{
              var newPath = __dirname + "/uploads/fullsize/" + imageName;
  
              fs.writeFile(newPath, data, function(err){
                  res.redirect("/uploads/fullsize/" + imageName);
              });
          }
  
      });
  });
  
  app.listen(8080);
  </code></pre>