typeerror: app.use() requires middleware function
This worked with me:
app.use(multer({
dest: path.join(__dirname, 'public/upload/temp')
}).any());
It worked in this way. delete this line,
app.use(multer({ dest: './uploads' }));
and use it as,
var multer = require('multer');
var upload = multer({ dest: './uploads' });
I'm too following the same course
Change:
//Handle File Uploads
app.use(multer({
dest: './uploads'
}));
For something like:
app.use(multer({dest:'./uploads/'}).single('singleInputFileName'));
or
app.use(multer({dest:'./uploads/'}).array('multiInputFileName'));
And be aware to have something like:
<form action="/postPhotos" enctype="multipart/form-data">
<input type="file" name="singleInputFileName">
<input type="submit" value="Upload photo">
</form>
for the first case, or:
<form action="/postPhotos" enctype="multipart/form-data">
<input type="file" name="multiInputFileName" multiple>
<input type="submit" value="Upload photo">
</form>
For the second one, in your html.