UPDATE: This is an older way to upload images using Express Body Parser, which is now deprecated. Please see the updated version Uploading and Resizing Images (on the fly) With Node.js and Express. Node.js is an awesome development platform that lets you build web applications with server-side javascript.  In this example I'll show you how to build a simple application that will allow you to upload a file to a server in a full size and thumbnail size format. First you need to have node installed on your machine.  Visit the node.js website for instructions on how to do this. Using your preferred terminal application, cd to the preferred location of your application and create your application folder:
mkdir uploadapp
Then navigate into this folder:
cd uploadapp
Next let's install the express.js framework. This is easily done with the following command from your app's folder:
npm install express
Now that we have our webframework, lets setup our server.
nano app.js
Add the following to app.js:
var express = require("express");
var app = express();

app.get('/', function (req, res){
  res.writeHead(200, {'Content-Type': 'text/plain' });
  res.end("Hello World!");
});

app.listen(8080);
Next inside your terminal start node on the app.js file:
node app.js
And go to http://localhost:8080 and you should see the following:
Hello World!
Now that we have our server working, let's build our uploader app. Replace the text in app.js with the following:
var express = require("express");
var app = express();

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);  
});

app.listen(8080);
Notice that now we have an upload form that will post the file to http://localhost:8080/upload. Let's create the folders where we want our images to go.
mkdir uploads
cd uploads
mkdir fullsize
mkdir thumbs
cd ../
So now we have the folder uploads that contains the folders fullsize and thumbs to contain our different image sizes. Now let's add the upload handling page, edit app.js to the look like the following:
var express = require("express");
var app = express();

// Include the express body parser
app.configure(function () {
  app.use(express.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);

});

// Include the node file module
var fs = require('fs');

// Post files
app.post('/upload', function(req, res) {
  fs.readFile(req.files.image.path, function (err, data) {
    var imageName = req.files.image.name
    // If there's an error
    if(!imageName){
      console.log("There was an error")
      res.redirect("/");
      res.end();
    } else {
      var newPath = __dirname + "/uploads/fullsize/" + imageName;
      // write file to uploads/fullsize folder
      fs.writeFile(newPath, data, function (err) {
        // let's see it
        res.redirect("/uploads/fullsize/" + imageName);
      });
    }
  });
});

app.listen(8080);
After we upload our file we want to be able to see it, so let's add a route to view our file.
/// Show files
app.get('/uploads/fullsize/:file', function (req, res){
  file = req.params.file;
  var img = fs.readFileSync(__dirname + "/uploads/fullsize/" + file);
  res.writeHead(200, {'Content-Type': 'image/jpg' });
  res.end(img, 'binary');

});
Now the full app.js file should look like this:
var app = express();

/// Include the express body parser
app.configure(function () {
  app.use(express.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);
});

// Include the node file module
var fs = require('fs');

// Post files
app.post('/upload', function(req, res) {
  fs.readFile(req.files.image.path, function (err, data) {
    var imageName = req.files.image.name
    // If there's an error
    if(!imageName){
      console.log("There was an error")
      res.redirect("/");
      res.end();
    } else {
      var newPath = __dirname + "/uploads/fullsize/" + imageName;
      // write file to uploads/fullsize folder
      fs.writeFile(newPath, data, function (err) {
        // let's see it
        res.redirect("/uploads/fullsize/" + imageName);
      });
    }
  });
});

// Show files
app.get('/uploads/fullsize/:file', function (req, res){
  file = req.params.file;
  var img = fs.readFileSync(__dirname + "/uploads/fullsize/" + file);
  res.writeHead(200, {'Content-Type': 'image/jpg' });
  res.end(img, 'binary');
});

app.listen(8080);
Let's upload a file and see if this works. Restart node on app.js and navigate to http://localhost:8080. Upload a file and you should be redirected to see your fullsize image. Now let's create the thumbnail version of this file. First we need to add a new module to our node stack to handle the resize. In your terminal at your app's root download the Image Magick package:
npm install imagemagick
Now edit app.js to look like this:
var express = require("express");
var app = express();

/// Include the express body parser
app.configure(function () {
  app.use(express.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);
});

// Include the node file module
var fs = require('fs');

// Include ImageMagick
var im = require('imagemagick');

// Post files
app.post('/upload', function(req, res) {
  fs.readFile(req.files.image.path, function (err, data) {
    var imageName = req.files.image.name
    /// If there's an error
    if(!imageName){
      console.log("There was an error")
      res.redirect("/");
      res.end();
    } else {
      var newPath = __dirname + "/uploads/fullsize/" + imageName;
      var thumbPath = __dirname + "/uploads/thumbs/" + imageName;
      // write file to uploads/fullsize folder
      fs.writeFile(newPath, data, function (err) {
        // write file to uploads/thumbs folder
        im.resize({
          srcPath: newPath,
          dstPath: thumbPath,
          width:   200
        }, function(err, stdout, stderr){
          if (err) throw err;
          console.log('resized image to fit within 200x200px');
        });
         res.redirect("/uploads/fullsize/" + imageName);
      });
    }
  });
});

// Show files
app.get('/uploads/fullsize/:file', function (req, res){
  file = req.params.file;
  var img = fs.readFileSync(__dirname + "/uploads/fullsize/" + file);
  res.writeHead(200, {'Content-Type': 'image/jpg' });
  res.end(img, 'binary');
});

app.get('/uploads/thumbs/:file', function (req, res){
  file = req.params.file;
  var img = fs.readFileSync(__dirname + "/uploads/thumbs/" + file);
  res.writeHead(200, {'Content-Type': 'image/jpg' });
  res.end(img, 'binary');
});

app.listen(8080);
If you get an error trying to use Image Magick, it may need to be installed on your machine. On a mac you can run the following command to install via brew:
brew install imagemagick
Go to http://localhost:8080 and you should now be able to upload two different versions of the file, fullsize and thumb located at: http://localhost:8080/uploads/fullsize/youruploadedfile http://localhost:8080/uploads/thumbs/youruploadedfile I hope you found this helpful. Hit me up on twitter if you have any questions/comments: @tonyspiro.