D
D
dfv1232017-10-21 16:14:24
Node.js
dfv123, 2017-10-21 16:14:24

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

1 answer(s)
F
Fudo Tsukiko, 2017-10-22
@FudoTsu

check request size

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question