I have a Node.js web app. In the app I'm using Express. I need to let a user upload a picture. To do that, I've reviewed some examples online, but none seem to meet my needs. Specifically, I want to get the file that was uploaded, save it to the local disk, and do some manipulation on it. Right now, I have the following:
const app = this;
const multer = require('multer')
const upload = multer({ dest: 'uploads/' })
app.post('/picture/upload', upload.single('picture'), function(req, res) {
console.log('uploaded');
var picture = req.file;
console.log(picture);
res.send({ id: 1, fileName: 'info', originalName: 'name' });
});
When I upload a file from my web page, I see the following in the console window:
uploaded
undefined
When I look in Fiddler, I can see that the image is being passed to the server. It's just like I'm not "accessing" it properly. How do I get an uploaded file on the server side in Node?
Thank you!
via user687554
No comments:
Post a Comment