title: How to find out file size in Node?
body: <p>I have an app to deduce the size of a file uploaded by the user. I have the code as follows</p>
  
  <p>The server.js code is as follows</p>
  
  <pre><code>var express = require('express');
  var formidable = require('express-formidable');
  var fs = require('fs');
  
  var app = express();
  
  var PORT = 8080;
  
  app.use(express.static(__dirname+'/views'));
  
  app.use(formidable.parse());
  
  app.set('views', './views');
  
  app.set('view engine', 'jade');
  
  app.get('/', function(req, res){
     res.render('index.jade'); 
  });
  </code></pre>
  
  <p>When I try to log the variable stats below, I get an error saying </p>
  
  <blockquote>
    <p>TypeError: path must be a string</p>
  </blockquote>
  
  <pre><code>app.post('/upload', function(req, res){
     var stats = fs.statSync(req.body);
     console.log(stats);
  });
  
  app.listen(PORT, function(){
      console.log('Express listening on port: '+PORT);
  });
  </code></pre>
  
  <p>The index.jade file is rendered below</p>
  
  <pre><code>html
      head
          link(rel='stylesheet', href='style.css', type='text/css')
          title Upload file for shortening
      body
          h1 Welcome to file metadata service
          div(id='upload-button')
              form(action='/upload', enctype='multipart/form-data')
                  input(name='Upload', type='file', id='upload-butt')
          div(id="submit-button")
              form(action = '/submit')
                  button(type="submit", value='Submit', id='submit-butt') Submit
  
          script(src="https://code.jquery.com/jquery-2.2.0.min.js")
          script(src="upload.js")
  </code></pre>
  
  <p>The css styling is below</p>
  
  <pre><code>#submit-butt{
      width:100px;
      height:auto;
      background-color:red;
      cursor:pointer;
      margin-left:150px;
  }
  
  #upload-butt{
      width:200px;
      height:auto;
      cursor:pointer;
      float:left;
  }
  
  h1{
      font-family:Impact;
  }
  </code></pre>
  
  <p>The jQuery code is given below</p>
  
  <pre><code>$('#upload-butt').on('click', function(){
     $('#upload-butt').on('change', function(){
        var file = $(this).get(0).files;
  
        if(file.length &gt; 0){
            var formData = new FormData();
            formData.append('Upload', file, file.name);
            $.ajax({
                url: '/upload', 
                type: 'POST',
                data:formData,
                processData:false,
                contentType:false,
                success: function(data){
                    console.log('upload successful: '+data);
                }
            })
        }
     });
  });
  </code></pre>
  
  <p>How do I deal with the TypeError? How do I convert the path to a string? What I have is the parsed data obtained after running through formidable middleware. </p>