I'm new in nodejs, and during the test of my post method that upload image from the computer I get in postman this message that shows that my upload method doesn't exist
my server.js code is
const express = require('express'); const multer = require('multer'); const app = express(); //moddleware app.use(express.urlencoded({extended: true})); app.use(multer.json('')); const PORT = process.env.PORT | 5000; var Storage = multer.diskStorage({ destination: (req, file, callback) => { callback(null,"/images"); }, filename: (req, file, callback) => { callback(null,file.fieldname); } }); var upload = multer({ storage: Storage }).array('image',3); //route app.post('/', (req, res) => {}); app.post('/upload', (req, res) => { upload(req, res , err => { if (err) { return res.send('somthing went wrong'); } return.res.send('file uploaded successfully'); }); }); app.listen(PORT, () => { console.log('Server running on PORT ${PORT}') });
and this is my server response
[nodemon] 2.0.7 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,json [nodemon] starting `node server.js` Server running on PORT ${PORT}
thank you
https://stackoverflow.com/questions/65820251/using-postman-to-upload-an-image-to-nodejs-backend-service January 21, 2021 at 10:10AM
没有评论:
发表评论