“upload de arquivo Multer Express” Respostas de código

upload de arquivo Multer Express

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)
});
Jittery Jellyfish

Carregue um arquivo usando o 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;
Javasper

Respostas semelhantes a “upload de arquivo Multer Express”

Perguntas semelhantes a “upload de arquivo Multer Express”

Mais respostas relacionadas para “upload de arquivo Multer Express” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código