Using example at express-fileupload Examples
<pre>
const express = require('express');
const fileUpload = require('express-fileupload');
const app = express();
// default options
app.use(fileUpload());
app.post('/upload', function(req, res) {
if (Object.keys(req.files).length == 0) {
return res.status(400).send('No files were uploaded.');
}
// The name of the input field (i.e. "sampleFile") is used to retrieve the uploaded file
let sampleFile = req.files.sampleFile;
// Use the mv() method to place the file somewhere on your server
sampleFile.mv('/somewhere/on/your/server/filename.jpg', function(err) {
if (err)
return res.status(500).send(err);
res.send('File uploaded!');
});
}); <code>
I get this error
nodejs server1.js /var/www/html/express/server1.js:14 let sampleFile = req.files.sampleFile; ^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
Something simple I'm sure. Even pasting the code here the 'let' statement is isolated.