title: Rename uploaded image in multer using fs
body: <p>When a user uploads a picture - I'm using multer by the way - with a name that contains a space, I want to replace the white-spaces with <code>"-"</code> before saving the file name to my Mysql table and then also rename the file that has been uploaded to the new name with the <code>"-"</code>.
  This is my code. It does rename and the Mysql table saves the new name with the hyphen but the image doesn't get uploaded for some reason, there's no error even, infact the POST request is actually successful.</p>
  
  <pre><code>router.post('/uploadpost', upload.single('image'), function(req, res){
  var name = req.file.originalname;
  var reName;
  if(/\s/g.test(name)){
      reName = name.replace(" ", "-");
      fs.rename(req.file.path, reName, function(err){
          if(err){
              throw err;
          }
  
      });
  }
  </code></pre>