Answer the question
In order to leave comments, you need to log in
How to check for empty content?
the code works like this. we take a picture from the im1 form, upload it to the cloud, save the link to the picchu in db. how to make an entry in the database if the picture did not come? those. the user sent everything except the picture.
app.post('/upload', multipartMiddleware, function(req, res) {
//console.log(req.files.im1.path);
var url = req.files.im1
cloudinary.uploader.upload(url.path, function(result) {
var image = new Image ({
image: result.url
question: req.body.question,
answer: req.body.answer
})
image.save()
.then(result => res.json(result))
.catch(e => next(e));
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question