title: fs writeFile create temp file in app root
body: <p>I have the following code snippet to up[load files to server. Its working as expected in local environment but not in web server. </p>
  
  <p>Using <a href="https://www.npmjs.org/package/connect-multiparty" rel="nofollow noreferrer">connect-multiparty</a></p>
  
  <pre><code>path = req.files.FIELDNAME.path;
  ogname = req.files.video.originalFilename;
  
  function(path , ogname, callback) {
  var fs = require('fs');
  var uploadDir = process.cwd() + "/public/uploads/";
  fs.readFile(path, function (err, data) {
    var originalFilename = new Date().getTime() + '-' + ogname.replace(/[\s,:-]+/g, "-");
    var newPath = uploadDir + originalFilename;
    var relatPath = "/uploads/" + originalFilename;
    fs.writeFile(newPath, data, function (err,result) {
      callback(relatPath);
    });
  });
  }
  </code></pre>
  
  <p>It creates files in <code>/public/uploads</code> as expected but leaves something in app root too. Like this </p>
  
  <p><img src="https://i.stack.imgur.com/prAbg.png" alt="enter image description here"></p>