Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

multer express file upload

const multer  = require('multer')
const upload = multer({ dest: './public/data/uploads/' })
app.post('/stats', upload.single('uploaded_file'), function (req, res) {
   // req.file is the name of your file in the form above, here 'uploaded_file'
   // req.body will hold the text fields, if there were any 
   console.log(req.file, req.body)
});
Comment

Upload a file using ExpressJS+Multer

var express = require('express');
var router = express.Router();
const multer  = require('multer');

const storage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, 'uploads/')
  },
  filename: function (req, file, cb) {
    cb(null, file.originalname)
  }
})
const upload = multer({storage: storage})

router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

router.post('/profile', upload.single('avatar'), function (req, res, next) {
})


module.exports = router;
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript sort an array 
Javascript :: javascript data 
Javascript :: scrollout js 
Javascript :: use react awesome slider in react js 
Javascript :: using python with javascript 
Javascript :: express js sample project 
Javascript :: what does sanitize do javascript 
Javascript :: axios defaults headers common 
Javascript :: how to print in java script 
Javascript :: vue router transition 
Javascript :: kendo grid toolbar custom button click event jquery 
Javascript :: singleton function javascript 
Javascript :: get current tab from chrome extension developer 
Javascript :: react class components 
Javascript :: javascript how to remove first element of array 
Javascript :: react router go back 
Javascript :: nestjs swagger 
Javascript :: javascript charcode 
Javascript :: js origin without port 
Javascript :: how to sort array least to greatest javascript stACK 
Javascript :: javascript == vs === 
Javascript :: Create JavaScript Strings 
Javascript :: react function 
Javascript :: css select all links in div 
Javascript :: react native image with header and body 
Javascript :: array with object same keys 
Javascript :: remove suffix string js 
Javascript :: usehistory() hook 
Javascript :: js delete all cookies 
Javascript :: math random javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =