“Ekspresikan Multer” Kode Jawaban

Multer di Express.js

const express = require('express')
const multer  = require('multer')
const upload = multer({ dest: 'uploads/' })

const 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
})

const 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
})
Zeamanual Feleke

Multer NPM

$ npm install --save multer file upload node 
Moise Mbakop

Ekspresikan Multer

$ npm install --save multer

var express = require("express");
var multer = require('multer');
var upload = multer({dest:'uploads/'});
Cloudy Crossbill

Jawaban yang mirip dengan “Ekspresikan Multer”

Pertanyaan yang mirip dengan “Ekspresikan Multer”

Lebih banyak jawaban terkait untuk “Ekspresikan Multer” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya