Answers for "how to send files express"

9

how to send html file with express

res.sendFile(path.join(__dirname + '/index.html'));
Posted by: Guest on March-05-2020
0

upload files to express using express-fileupload

const fileUpload = require('express-fileupload');
app.post('/upload', fileUpload, (req, res) => {
  //Now you can use req.files.file to access the file input with name="file"
  user.avatar = {data: req.files.file.data, contentType: req.files.file.mimetype};
  //Now perform user.save
})
Posted by: Guest on April-27-2022

Browse Popular Code Answers by Language