Use multer for File-Uploads inside a Express Router
Ok, I got it.
I can use
var multer = require("multer")
var upload = multer({ dest: "some/path" })
[...]
router.route("/upload")
/* replace foo-bar with your form field-name */
.post(upload.single("foo-bar"), function(req, res){
[...]
})
In my case i try every thing but it not works but i come over the solution
app.js
const multer = require('multer');
const storage = {
dest: 'UPLOAD/PATH/'
}
const upload = multer(storage);
app.post('/myupload', upload.single('FILE_NAME'), (req,res)=>{
res.send('Upload');
});
i tried many times with express.Router() but it not works that's why i write code in app.js and redirect to another file.
For me, it also worked.
var multer = require("multer")
var upload = multer({ dest: "path" })
router.post("/upload", upload.single("foo-bar"), function(req, res) {
...
}