filmov
tv
How to upload multiple Photos with multer and node modules?

Показать описание
(a cautionary note, YouTube doesn't allow the greater than symbol in the description so I'm forced to use a unicode lookalike ⋗, please replace it if you copy and paste code from here)
1. At this point we will start adding the ability to upload files from a client request to our server using multer, for that we will add the highlighted code to our REST API:
import express, {json, urlencoded} from 'express'
import morgan from 'morgan'
import morganBody from 'morgan-body'
import multer from 'multer'
// Multer
destination: function (req, file, cb) {
cb(null, 'uploads/')
},
filename: function (req, file, cb) {
if (extension === 'x-javascript') extension = 'js'
if (extension === 'video/quicktime') extension = 'mov'
if (extension === 'video/x-msvideo') extension = 'avi'
}
})
const upload = multer({ storage: storage })
const app=express()
'Access-Control-Allow-Methods': 'PUT, POST, GET'
})
}
})
morganBody(app)
const upload_files = (req, res) =⋗ {
// this function will handle the actions that follow the uploading of the files by multer
}
/****************************************************************/
/* HERE WE SET UP A ROUTE THAT WILL LISTEN TO POST REQUESTS IN */
/* THE /upload_files ROUTE */
})
1. At this point we will start adding the ability to upload files from a client request to our server using multer, for that we will add the highlighted code to our REST API:
import express, {json, urlencoded} from 'express'
import morgan from 'morgan'
import morganBody from 'morgan-body'
import multer from 'multer'
// Multer
destination: function (req, file, cb) {
cb(null, 'uploads/')
},
filename: function (req, file, cb) {
if (extension === 'x-javascript') extension = 'js'
if (extension === 'video/quicktime') extension = 'mov'
if (extension === 'video/x-msvideo') extension = 'avi'
}
})
const upload = multer({ storage: storage })
const app=express()
'Access-Control-Allow-Methods': 'PUT, POST, GET'
})
}
})
morganBody(app)
const upload_files = (req, res) =⋗ {
// this function will handle the actions that follow the uploading of the files by multer
}
/****************************************************************/
/* HERE WE SET UP A ROUTE THAT WILL LISTEN TO POST REQUESTS IN */
/* THE /upload_files ROUTE */
})