Nodejs and multer cannot upload files

  node.js, question

Html code

<form method="post" class="upload" action="/jsreview/upload" enctype='multipart/form-data'>
 <input type="file"  name='jsfile' accept="text/javascript,application/javascript"/>
 <input type="submit" />
 </form>

Js code:

var multer = require('multer');
 Varupload = multer ({dest: _ dirname plus' /files/'});
 var app = express();
 app.use(express.static('./'));
 app.get('/jsreview',function(req,rsp){
 rsp.sendfile('./index.html');
 });
 app.post('/jsreview/upload',upload.single('jsfile'),function(req,rsp){
 console.log(req.body,req.files);
 rsp.send('success');
 });
 app.listen(12345);

After selecting the file and clicking the submit button, console.log outputs {} and undefined. I grabbed the next bag and showed it

Request Payload:
 
 ------WebKitFormBoundary3bQrxuFKQA21XmiJ
 Content-Disposition: form-data;   name="jsfile";  Filename= "new text document.js"
 Content-Type: application/javascript
 
 ------WebKitFormBoundary3bQrxuFKQA21XmiJ--

Great gods help me see what’s wrong.

I have checked that I have no problem to upload.

You check if your __dirname is correct;

First change to try varupload = multer ({dest:’ upload/files’});