Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 設定 storage
- const storage = multer.diskStorage({
- // 設定檔案存取位置
- destination: function (req, file, cb) {
- cb(null, 'images')
- },
- // 設定檔案命名方式
- filename: function (req, file, cb) {
- cb(null, new Date().toISOString() + '-' + file.originalname)
- }
- })
- // 設定 fileFilter
- // 設定 Multer
- const upload = multer({
- limit: {
- // 限制上傳檔案的大小為 1MB
- fileSize: 1000000
- },
- fileFilter,
- storage
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement