multer()
var multer = require('multer');
var upload = multer({dest:'uploads/'});
multer()
var multer = require('multer');
var upload = multer({dest:'uploads/'});
multer npm
$ npm install --save multer file upload node
multer
var express = require('express')var app = express()var multer = require('multer')var upload = multer() app.post('/profile', upload.none(), function (req, res, next) { // req.body contains the text fields})
multer
var express = require('express')var multer = require('multer')var upload = multer({ dest: 'uploads/' }) var app = express() app.post('/profile', upload.single('avatar'), function (req, res, next) { // req.file is the `avatar` file // req.body will hold the text fields, if there were any}) app.post('/photos/upload', upload.array('photos', 12), function (req, res, next) { // req.files is array of `photos` files // req.body will contain the text fields, if there were any}) var cpUpload = upload.fields([{ name: 'avatar', maxCount: 1 }, { name: 'gallery', maxCount: 8 }])app.post('/cool-profile', cpUpload, function (req, res, next) { // req.files is an object (String -> Array) where fieldname is the key, and the value is array of files // // e.g. // req.files['avatar'][0] -> File // req.files['gallery'] -> Array // // req.body will contain the text fields, if there were any})
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us