title: How to add an array of images to a Mongo database
body: <p>I use a formidable plugin and I only work on one image, when I upload several images together the code overwrites the next image and does not display,
  I want to add an array of images to the database</p>
  <p>my code :</p>
  <pre><code>exports.create = (req, res) =&gt; {
      let form = new formidable.IncomingForm()
      form.multiples = true;
      form.keepExtensions = true;
  
      form.parse(req, (err, fields, files) =&gt;{
          if(err) {
              return res.status(400).json({
                  error: &quot;Image could not be uploaded&quot;
              });
          }
  
          //check for all fields
          const { name, description, price, category, quantity, shipping, color, size } = fields;
          
          if (!name || !description || !price || !category || !quantity || !shipping || !color || !size) {
              return res.status(400).json({
                      error: &quot;All fields are required&quot;
                  });
          }
  
          let product = new Product(fields);
          const file = files;
          if(files.photo){
              for (let i = 0; i &lt; file.length; i++){
              if(files.photo.size &gt; 1000000) {
                  return res.status(400).json({
                      error: &quot;Image should be less then 1mb in size&quot;
                  });
              }
              product.photo.data = fs.readFileSync(files.photo.path);
              product.photo.contentType = files.photo.type;
          }}
          product.save((err, result) =&gt;{
              if(err){
                  return res.status(400).json({
                      error: errorHandler(error)
                  });
              }
              res.json(result);
              console.log(result)
          });
      });
  };
  </code></pre>