title: Not able to get full path name of file in html form for express mutler
body: <p>I am having some difficulty getting the full path for a file from a form html. I understand that browser do not allow that. I have done some search in stackoverflow and unable to resolve the issue. I may have missed out something simple or straight forward. </p>
  
  <p>The task is to open a file (etc "readme.txt") from user selected location. If  the file is from the same folder location as the script, it will work. If the file is in a different folder, it will fail. The error stack is as below.</p>
  
  <p>Basically I am using a html form , and the server is express and mutler. Using postman , I am able to open the file by specifying the full path in postman, so I conclude the problem lies in the form as I am not able to get the full path of the file. </p>
  
  <p>My question (after quite some inconclusive search of googling / stackoverflow) : how do I get the full pathname for the file through the html form ? If I can't (due to browser security), what are the ways that I can go around this as I like to open the file. </p>
  
  <p>Thanks for pointing me to the right direction (or searches) !</p>
  
  <pre><code>    &lt;form method="POST" action="http://localhost:3000/upload" &gt;
          &lt;div&gt;
              &lt;label&gt;Select your profile picture:&lt;/label&gt;
              &lt;input type="file" name="file" /&gt;
          &lt;/div&gt;
          &lt;div&gt;
              &lt;input type="submit" name="btn_upload_profile_pic" value="Upload" /&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>server </p>
  
  <pre><code>
  var express = require('express')
  var bodyParser = require ('body-parser')
  var fs = require ('fs')
  var multer = require('multer')
  
  const port = process.env.PORT || 3000
  const app = express ();
  
  
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());
  
  
  
  const storage = multer.diskStorage({
      destination: function(req, file, cb) {
          cb(null, 'uploads/');
      },
  
      // By default, multer removes file extensions so let's add them back
      filename: function(req, file, cb) {
          cb(null, file.fieldname + '-' + Date.now() + path.extname(file.originalname));
      }
  })
  
  var upload = multer({ storage: storage })
  
  
  app.post ("/upload",  (req, res)=&gt;{
  
  
      console.log (JSON.stringify (req.body.file))
  
  
      const content = fs.readFileSync(req.body.file, 'utf8');
      console.log(content);
  
      res.send (content)
  
  
  })
  
  
  app.listen (port, ()=&gt;{
  
      console.log ('Server is up on port ' + port)
  })
  </code></pre>
  
  <p>The error stack if I open the file (from the html form) from another a different location</p>
  
  <pre><code>Error: ENOENT: no such file or directory, open 'readmefolder.txt'
      at Object.openSync (fs.js:451:3)
      at Object.readFileSync (fs.js:353:35)
      at /Users/dev/Development/node/mutlertest/playground/servertest.js:44:24
      at Layer.handle [as handle_request] (/Users/dev/Development/node/mutlertest/node_modules/express/lib/router/layer.js:95:5)
      at next (/Users/dev/Development/node/mutlertest/node_modules/express/lib/router/route.js:137:13)
      at Route.dispatch (/Users/dev/Development/node/mutlertest/node_modules/express/lib/router/route.js:112:3)
      at Layer.handle [as handle_request] (/Users/dev/Development/node/mutlertest/node_modules/express/lib/router/layer.js:95:5)
      at /Users/dev/Development/node/mutlertest/node_modules/express/lib/router/index.js:281:22
      at Function.process_params (/Users/dev/Development/node/mutlertest/node_modules/express/lib/router/index.js:335:12)
      at next (/Users/dev/Development/node/mutlertest/node_modules/express/lib/router/index.js:275:10)
  
  </code></pre>