Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #upload #files #express
ADD COMMENT
Topic
Name
6+4 =