title: NPM Multer returning no response
body: <p>I am trying to upload a file using <code>npm multer</code>. The issue is multer is returning no response, not even error. I tried to create the common function for whole application for file upload. <strong>I have all (777) permission to my folder as well.</strong> </p>
  
  <p>My sample code is.</p>
  
  <pre><code>var uploadFile = require('../../utilities/common').uploadFile;
  exports.uploadVehicle    = function (req, res) {
      console.log('\nUploading File');
      console.log(dirPath.vehicleFarm);
      uploadFile(dirPath.vehicleFarm, 'csvFile', function (err) {
          console.log('\tError:');
          console.log(err);
          if (err)
              return res.status(err.status || 400).json({code: err.status || 400, message: err.message || 'Unable to process request.'});
          var data = req.body;
          console.log(data.csvFile);
          res.status(200).json({status: 200, message: 'File saved successfully'});
      });
  };
  </code></pre>
  
  <p>The <code>uploadFile</code> function in common file is mentioned like this.</p>
  
  <pre><code>var multer         = require('multer');
  var path           = require('path');
  var fs             = require('fs');
  var filePath       = path.resolve(__dirname, '..');
  var storage        = function (inputDir, fieldName) {
      console.log('Input from storage to path - ' + inputDir);
      console.log(filePath + '/uploads/' + inputDir);
      return multer.diskStorage({
          destination: function (req, file, cb) {
              cb(null, filePath + '/uploads/' + inputDir);
          },
          filename   : function (req, file, cb) {
              var dateTimeStamp   = Date.now();
              req.body[fieldName] = file.fieldname + '-' + dateTimeStamp + '.' + file.originalname.split('.')[file.originalname.split('.').length - 1];
              console.log(req.body[fieldName]);
              cb(null, req.body[fieldName]);
          }
      });
  };
  exports.uploadFile = function (inputDir, fieldName) {
      return multer({storage: storage(inputDir, fieldName)}).single(fieldName);
  };
  </code></pre>
  
  <p>Input path is also valid even the folder also exists Path is - <code>/home/sony/Desktop/node/all/db/uploads/tempCSV/vehicleFarm/</code></p>
  
  <p>Where I have mistaken? How would I trace if file uploads fails as well?</p>