title: Error: EXDEV: cross-device link not permitted, rename
body: <p>There are many question similar to my question on stack overflow. However not solved my problem.</p>
  
  <p>I am getting this error on Ubuntu 18.04:</p>
  
  <p><strong>Error: EXDEV: cross-device link not permitted, rename 
  '/tmp/upload_df97d265c452c510805679f968bb4c17' -> '/home/haider/workspaceNode/DSC_0076.JPG'</strong></p>
  
  <p>I Tried This code  </p>
  
  <pre><code> var http = require('http');
      var formidable = require('formidable');
      var fs = require('fs');
  
  http.createServer(function (req, res) {
    if (req.url == '/fileupload') {
      var form = new formidable.IncomingForm();
      form.parse(req, function (err, fields, files) {
        var oldpath = files.filetoupload.path;
        var newpath = '/home/haider/workspaceNode/' + files.filetoupload.name;
        fs.rename(oldpath, newpath, function (err) {
          if (err) throw err;
          res.write('File uploaded and moved!');
          res.end();
        });
   });
    } else {
      res.writeHead(200, {'Content-Type': 'text/html'});
      res.write('&lt;form action="fileupload" method="post" enctype="multipart/form-data"&gt;');
      res.write('&lt;input type="file" name="filetoupload"&gt;&lt;br&gt;');
      res.write('&lt;input type="submit"&gt;');
      res.write('&lt;/form&gt;');
      return res.end();
    }
  }).listen(8081);
  </code></pre>