Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. // 設定 storage
  2. const storage = multer.diskStorage({
  3. // 設定檔案存取位置
  4. destination: function (req, file, cb) {
  5. cb(null, 'images')
  6. },
  7. // 設定檔案命名方式
  8. filename: function (req, file, cb) {
  9. cb(null, new Date().toISOString() + '-' + file.originalname)
  10. }
  11. })
  12.  
  13. // 設定 fileFilter
  14.  
  15. // 設定 Multer
  16. const upload = multer({
  17. limit: {
  18. // 限制上傳檔案的大小為 1MB
  19. fileSize: 1000000
  20. },
  21. fileFilter,
  22. storage
  23. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement